Hello.

I have problems running 2 commands.
When the second COMMAND2 fail this return os.Exit(2) but my program never 
finish. If I see the process using ps ax I can see COMMAND2 <defunct>

If I run this 2 programs in linux command line, this work fine, but doesnt 
work in go.

Could you help me? please

Thanks ins advance

This is my code

var cmd1_stderr bytes.Buffer
cmd1 := exec.Command("COMMAND1", args_1...)
cmd1.Stderr = &cmd1_stderr

var cmd2_stderr bytes.Buffer
cmd2 := exec.Command("COMMAND2", args_2...)
cmd2.Stderr = &cmd2_stderr

pipe, err := cmd1.StdoutPipe()
if err != nil {
    // show error
}
cmd2.Stdin = pipe

err1 := cmd1.Start()
err2 := cmd2.Start()

if err1 == nil && err2 == nil {
    done := make(chan error, 1)
    go func() {
        done <- cmd1.Wait()
        done <- cmd2.Wait()
    }()

    select {
        case cmd_err := <-done: // process finish
            if cmd_err != nil {
                // show error
            } else {
                // finish ok
            }
    }
}


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to