Browse Source

commenting code

tags/version-1.0
Vladimir Smagin 8 months ago
parent
commit
4e575034f6
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      file_utils.go

+ 4
- 1
file_utils.go View File

@@ -63,12 +63,13 @@ func runCmd(ctx context.Context, env []string, cmdname string, params ...string)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

//cmd.Start()
// run su command in PTY
f, err := pty.Start(cmd)
if err != nil {
panic(err)
}
io.Copy(os.Stdout, f)

// Use a channel to signal completion so we can use a select statement
done := make(chan error)
go func() { done <- cmd.Wait() }()
@@ -79,6 +80,8 @@ func runCmd(ctx context.Context, env []string, cmdname string, params ...string)
case <-ctx.Done():
// Timeout happened first, kill the process and print a message.
cmd.Process.Signal(syscall.SIGTERM)
// graceful stop 10 seconds
// if task must be killed instead of normal termination
time.AfterFunc(10*time.Second, func() {
if !cmd.ProcessState.Exited() {
cmd.Process.Kill()

Loading…
Cancel
Save