Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-17 Thread Salvatore Domenick Desiano
There might be. Or I might be holding it wrong. I'm about to post another thread with a different angle on this. This thread was mis-framed. On Mon, Jun 17, 2024 at 1:16 PM Harri L wrote: > I’m wondering if there’s a specific reason you’re using io.Pipe instead > of the Cmd.StdoutPipe helper? Wh

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-17 Thread Harri L
I’m wondering if there’s a specific reason you’re using io.Pipe instead of the Cmd.StdoutPipe helper? When using io.Pipe you need to Close the pipe by yourself, but when using the Cmd.StdoutPipe, the Cmd.Wait will close the pipe for you. Here’s a sample following your previous example: func m

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Salvatore Domenick Desiano
Ah! I apologize... in reducing it to a compact example I didn't notice that I changed the semantics of what the code was doing. You are, of course, right about the cause of the deadlock in this code. That said, working backward from the self-contained example to my full code clarified the actual

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Robert Engels
It hangs because cmd.Run() waits for the process to complete - and with nothing reading the pipe it will never complete. On Jun 16, 2024, at 9:33 PM, Robert Engels wrote:It looks like you don’t have anything reading from the pipe so it’s going to hang. On Jun 16, 2024, at 8:54 PM, Salvatore Domen

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Robert Engels
It looks like you don’t have anything reading from the pipe so it’s going to hang. On Jun 16, 2024, at 8:54 PM, Salvatore Domenick Desiano wrote:Simpler self-contained example, same result:func main() { cmdName := "/bin/bash" cmdArgs := []string{"-c", "while true; do echo step; sleep 1; done"}cmd

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Salvatore Domenick Desiano
Simpler self-contained example, same result: func main() { cmdName := "/bin/bash" cmdArgs := []string{"-c", "while true; do echo step; sleep 1; done"} cmdStdoutR, cmdStdoutW := io.Pipe() cmd := exec.Command(cmdName, cmdArgs...) cmd.Stdout = cmdStdoutW if err := cmd.Run(); err != nil { fmt.Print

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Salvatore Domenick Desiano
I hope this isn't a red herring but in constructing a self-contained example I triggered a deadlock. Perhaps the deadlock is the answer to my question or perhaps it is another issue. Either way this code does not seem malformed: func main() { cmdName := "/bin/bash" cmdArgs := []string{ "-c", "w

Re: [go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Ian Lance Taylor
On Sun, Jun 16, 2024 at 3:20 PM Salvatore Domenick Desiano wrote: > > I'm hoping y'all can help me get the correct semantics for code that sets up > an external process, replaces Stdin, Stderr, Stdout, runs the command, calls > exec.Command.Wait() and handles SIGKILL correctly. > > I've read mor

[go-nuts] Fwd: cmd.Wait & io.Pipe & SIGKILL

2024-06-16 Thread Salvatore Domenick Desiano
I'm hoping y'all can help me get the correct semantics for code that sets up an external process, replaces Stdin, Stderr, Stdout, runs the command, calls exec.Command.Wait() and handles SIGKILL correctly. I've read more than two dozen threads, PRs, and bug reports about how exec.Command interacts