From ff7b245a31394b700a252fd547cf16ad0ad838b6 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sat, 10 Nov 2018 08:32:45 +1100 Subject: [PATCH] Revert "os: remove sleep in windows Process.Wait" This reverts CL 145221 (commit 5c359736f8d67338b53c26aaef52139ae8cd0538) Reason for revert: breaks the build occasionally. Updates #23171 Updates #25965 Change-Id: Ie1e3c76ab9bcd8d28b6118440b5f80c76f9b1852 Reviewed-on: https://go-review.googlesource.com/c/148957 Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/os/exec_windows.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/os/exec_windows.go b/src/os/exec_windows.go index 86b52f69bf976..38293a0d285f4 100644 --- a/src/os/exec_windows.go +++ b/src/os/exec_windows.go @@ -35,6 +35,12 @@ func (p *Process) wait() (ps *ProcessState, err error) { return nil, NewSyscallError("GetProcessTimes", e) } p.setDone() + // 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. + // See https://golang.org/issue/25965 for details. + defer time.Sleep(5 * time.Millisecond) defer p.Release() return &ProcessState{p.Pid, syscall.WaitStatus{ExitCode: ec}, &u}, nil }