os: sleep 5ms after process has exited on windows

Fixes #2866.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5719047
This commit is contained in:
Alex Brainman 2012-03-02 16:35:42 +11:00
parent 718de6f4c6
commit d1bd332a67
1 changed files with 5 additions and 0 deletions

View 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
}