From 5c2cce2da231a512c1c871c406d267d6d92679a1 Mon Sep 17 00:00:00 2001 From: 兔子 Date: Mon, 27 Jul 2020 14:19:05 +0800 Subject: [PATCH] cli bug fix --- process.go | 1 + process_linux.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/process.go b/process.go index 31427a5..12916b9 100644 --- a/process.go +++ b/process.go @@ -45,6 +45,7 @@ func Command(command string, args ...string) (*StarCmd, error) { shell.stdoutBuf = bytes.NewBuffer(make([]byte, 0)) shell.stderrBuf = bytes.NewBuffer(make([]byte, 0)) shell.runningChan = make(chan int, 3) + shell.stopctx, shell.stopctxfunc = context.WithCancel(context.Background()) cmd := exec.Command(command, args...) shell.CMD = cmd shell.infile, err = shell.CMD.StdinPipe() diff --git a/process_linux.go b/process_linux.go index 7f89641..d54e5c4 100644 --- a/process_linux.go +++ b/process_linux.go @@ -162,10 +162,10 @@ func (starcli *StarCmd) Release() error { if err := starcli.CMD.Start(); err != nil { return err } - starcli.cmd.SysProcAttr = &syscall.SysProcAttr{ + starcli.CMD.SysProcAttr = &syscall.SysProcAttr{ Setsid: true, } - starcli.cmd.Process.Release() + starcli.CMD.Process.Release() return nil }