dump the process exit value

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-04-06 05:35:07 -07:00
parent d9357e9e2d
commit eaee67e438
2 changed files with 5 additions and 4 deletions

View File

@ -75,7 +75,7 @@ func format(mybut *ui.Button) {
simpleProcess("ls -l")
os.Chdir("/mnt")
simpleProcess("pwd")
simpleProcess("ls -l")
simpleProcess("ls -l /aksd")
return
simpleProcess("parted -s /dev/sdb mklabel msdos")
simpleProcess("parted -s /dev/sdb mkpart primary ext4 1MiB 8GB")

View File

@ -70,6 +70,7 @@ func simpleProcess(cmd string) {
// cmd := exec.Command("ls", "/tmp", "/ballon", "/")
cmdArgs := strings.Fields(cmd)
(a, b) := strings.Fields(cmd)
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
stdout, _ := process.StdoutPipe()
stderr, _ := process.StderrPipe()
@ -79,8 +80,6 @@ func simpleProcess(cmd string) {
fmt.Println("start ls /tmp pid =", pid)
log.Println(reflect.ValueOf(process.Process).Elem())
log.Println(reflect.TypeOf(process.Process))
spew.Dump(process)
merged := io.MultiReader(stderr, stdout)
scanner := bufio.NewScanner(merged)
@ -95,7 +94,9 @@ func simpleProcess(cmd string) {
// One must wait for the process to formally finish and flush all buffer output
process.Wait()
log.Println("END " + cmd)
spew.Dump(process.ProcessState)
err := process.ProcessState // this should be the exit code of the process
log.Println("END " + cmd, err)
}
func exampleScanner() {