Last active
May 31, 2019 02:55
-
-
Save songjiayang/f87186e4ad3e6922fd4668447800accc to your computer and use it in GitHub Desktop.
cmd.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd := exec.Cmd{ | |
Path: command, | |
} | |
cmd.Stdout = os.Stdout | |
// start app | |
if err := cmd.Start(); err != nil { | |
log.Panic(err) | |
} | |
if err := cmd.Wait(); err != nil { | |
fmt.Println("cmd return with error:", err) | |
} | |
status := cmd.ProcessState.Sys().(syscall.WaitStatus) | |
fmt.Println(status.ExitStatus()) | |
if status.Signaled() { | |
fmt.Println(status.Signal()) | |
} | |
cmd.Process.Kill() | |
fmt.Println("after kill") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment