]> Cypherpunks repositories - gostls13.git/commitdiff
os: sleep 5ms after process has exited on windows
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 2 Mar 2012 05:35:42 +0000 (16:35 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 2 Mar 2012 05:35:42 +0000 (16:35 +1100)
Fixes #2866.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5719047

src/pkg/os/exec_windows.go

index fa58020c03120be245d999b72dda9a5e7fc455ba..5beca4a6509650c80f14b3f49d64e1d05e368aad 100644 (file)
@@ -33,6 +33,11 @@ func (p *Process) wait() (ps *ProcessState, err error) {
                return nil, NewSyscallError("GetProcessTimes", e)
        }
        p.done = true
+       // NOTE(brainman): It seems that sometimes process is not dead
+       // when WaitForSingleObject returns. But we do not know any
+       // other way to wait for it. Sleeping for a while seems to do
+       // the trick sometimes. So we will sleep and smell the roses.
+       defer time.Sleep(5 * time.Millisecond)
        defer p.Release()
        return &ProcessState{p.Pid, syscall.WaitStatus{ExitCode: ec}, &u}, nil
 }