dump the process exit value
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
d9357e9e2d
commit
eaee67e438
|
@ -75,7 +75,7 @@ func format(mybut *ui.Button) {
|
||||||
simpleProcess("ls -l")
|
simpleProcess("ls -l")
|
||||||
os.Chdir("/mnt")
|
os.Chdir("/mnt")
|
||||||
simpleProcess("pwd")
|
simpleProcess("pwd")
|
||||||
simpleProcess("ls -l")
|
simpleProcess("ls -l /aksd")
|
||||||
return
|
return
|
||||||
simpleProcess("parted -s /dev/sdb mklabel msdos")
|
simpleProcess("parted -s /dev/sdb mklabel msdos")
|
||||||
simpleProcess("parted -s /dev/sdb mkpart primary ext4 1MiB 8GB")
|
simpleProcess("parted -s /dev/sdb mkpart primary ext4 1MiB 8GB")
|
||||||
|
|
|
@ -70,6 +70,7 @@ func simpleProcess(cmd string) {
|
||||||
// cmd := exec.Command("ls", "/tmp", "/ballon", "/")
|
// cmd := exec.Command("ls", "/tmp", "/ballon", "/")
|
||||||
|
|
||||||
cmdArgs := strings.Fields(cmd)
|
cmdArgs := strings.Fields(cmd)
|
||||||
|
(a, b) := strings.Fields(cmd)
|
||||||
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
process := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
||||||
stdout, _ := process.StdoutPipe()
|
stdout, _ := process.StdoutPipe()
|
||||||
stderr, _ := process.StderrPipe()
|
stderr, _ := process.StderrPipe()
|
||||||
|
@ -79,8 +80,6 @@ func simpleProcess(cmd string) {
|
||||||
fmt.Println("start ls /tmp pid =", pid)
|
fmt.Println("start ls /tmp pid =", pid)
|
||||||
log.Println(reflect.ValueOf(process.Process).Elem())
|
log.Println(reflect.ValueOf(process.Process).Elem())
|
||||||
log.Println(reflect.TypeOf(process.Process))
|
log.Println(reflect.TypeOf(process.Process))
|
||||||
spew.Dump(process)
|
|
||||||
|
|
||||||
|
|
||||||
merged := io.MultiReader(stderr, stdout)
|
merged := io.MultiReader(stderr, stdout)
|
||||||
scanner := bufio.NewScanner(merged)
|
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
|
// One must wait for the process to formally finish and flush all buffer output
|
||||||
process.Wait()
|
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() {
|
func exampleScanner() {
|
||||||
|
|
Loading…
Reference in New Issue