瀏覽代碼

commenting code

tags/version-1.0
Vladimir Smagin 3 月之前
父節點
當前提交
4e575034f6
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4
    1
      file_utils.go

+ 4
- 1
file_utils.go 查看文件

@@ -63,12 +63,13 @@ func runCmd(ctx context.Context, env []string, cmdname string, params ...string)
63 63
 	cmd.Stdout = os.Stdout
64 64
 	cmd.Stderr = os.Stderr
65 65
 
66
-	//cmd.Start()
66
+	// run su command in PTY
67 67
 	f, err := pty.Start(cmd)
68 68
 	if err != nil {
69 69
 		panic(err)
70 70
 	}
71 71
 	io.Copy(os.Stdout, f)
72
+
72 73
 	// Use a channel to signal completion so we can use a select statement
73 74
 	done := make(chan error)
74 75
 	go func() { done <- cmd.Wait() }()
@@ -79,6 +80,8 @@ func runCmd(ctx context.Context, env []string, cmdname string, params ...string)
79 80
 	case <-ctx.Done():
80 81
 		// Timeout happened first, kill the process and print a message.
81 82
 		cmd.Process.Signal(syscall.SIGTERM)
83
+		// graceful stop 10 seconds
84
+		// if task must be killed instead of normal termination
82 85
 		time.AfterFunc(10*time.Second, func() {
83 86
 			if !cmd.ProcessState.Exited() {
84 87
 				cmd.Process.Kill()

Loading…
取消
儲存