On Thu, Jul 9, 2020 at 5:52 PM Ian Gudger <[email protected]> wrote:
>
> Thanks for pointing me to the bug.
>
> This is happening to me even with nil or *os.File Stdout and Stderr (I tried 
> both). Is there anything that can be done to guarantee that exec.Cmd.Wait 
> won't block indefinitely? I don't think my subprocess is starting any of its 
> own subprocesses, but I am not completely certain.

If you aren't setting Stdout or Stderr, then it's probably not that issue.

The next debugging step would be to run the program under strace -f,
to verify that the child process is being killed and to find out what
is happening with the wait system call.  I agree that what you
describe shouldn't happen.

Ian


> On Thu, Jul 9, 2020 at 4:15 PM Ian Lance Taylor <[email protected]> wrote:
>>
>> On Thu, Jul 9, 2020 at 4:14 PM Ian Gudger <[email protected]> wrote:
>> >
>> > I am using Go 1.14 AMD64 on Linux 5.3.0.
>> >
>> > When I create a subprocess with exec.Cmd.Start, I can't seem to fully kill 
>> > it with exec.Cmd.Process.Kill, or at least not to the satisfaction of 
>> > exec.Cmd.Wait.
>> >
>> > I am doing something along the lines of:
>> > cmd := exec.Command(binPath)
>> > if err := cmd.Start(); err != nil {
>> > ...
>> > }
>> > if err := cmd.Process.Kill(); err != nil {
>> > ...
>> > }
>> > if err := cmd.Wait(); err != nil {
>> > ...
>> > }
>> >
>> > However, this hangs on Wait. As far as I can tell this shouldn't happen. 
>> > Any idea what I might be doing wrong?
>>
>> Does the subprocess start any subprocesses itself?  Are you capturing
>> Stdout or Stderr into a bytes.Buffer or similar?  See
>> https://golang.org/issue/23019.
>>
>> Ian

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUPxkJ1NHd50YDiMf7mik%3D%3D-TCF6mXQmg9DN%2Bpjtu4-Tg%40mail.gmail.com.

Reply via email to