aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_posix_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-02-28 15:01:38 -0800
committerIan Lance Taylor <iant@golang.org>2017-03-01 02:02:40 +0000
commit15442178c801476f873b0678a99b27f06c8e38d6 (patch)
tree8947bf9fded863b2875afada669fbe76c425659d /src/os/exec/exec_posix_test.go
parentd945b286758d034b3bb07cbf3a4055b90684c38b (diff)
downloadgo-15442178c801476f873b0678a99b27f06c8e38d6.tar.gz
go-15442178c801476f873b0678a99b27f06c8e38d6.zip
os: don't use waitid on Darwin
According to issue #19314 waitid on Darwin returns if the process is stopped, even though we specify WEXITED. Fixes #19314. Change-Id: I95faf196c11e43b7741efff79351bab45c811bc2 Reviewed-on: https://go-review.googlesource.com/37610 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/os/exec/exec_posix_test.go')
-rw-r--r--src/os/exec/exec_posix_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/os/exec/exec_posix_test.go b/src/os/exec/exec_posix_test.go
index b1f24d6c4e..865b6c3ced 100644
--- a/src/os/exec/exec_posix_test.go
+++ b/src/os/exec/exec_posix_test.go
@@ -11,6 +11,7 @@ import (
"strconv"
"syscall"
"testing"
+ "time"
)
func TestCredentialNoSetGroups(t *testing.T) {
@@ -43,3 +44,40 @@ func TestCredentialNoSetGroups(t *testing.T) {
t.Errorf("Failed to run command: %v", err)
}
}
+
+// For issue #19314: make sure that SIGSTOP does not cause the process
+// to appear done.
+func TestWaitid(t *testing.T) {
+ t.Parallel()
+
+ cmd := helperCommand(t, "sleep")
+ if err := cmd.Start(); err != nil {
+ t.Fatal(err)
+ }
+
+ // The sleeps here are unnecessary in the sense that the test
+ // should still pass, but they are useful to make it more
+ // likely that we are testing the expected state of the child.
+ time.Sleep(100 * time.Millisecond)
+
+ if err := cmd.Process.Signal(syscall.SIGSTOP); err != nil {
+ cmd.Process.Kill()
+ t.Fatal(err)
+ }
+
+ ch := make(chan error)
+ go func() {
+ ch <- cmd.Wait()
+ }()
+
+ time.Sleep(100 * time.Millisecond)
+
+ if err := cmd.Process.Signal(syscall.SIGCONT); err != nil {
+ t.Error(err)
+ syscall.Kill(cmd.Process.Pid, syscall.SIGCONT)
+ }
+
+ cmd.Process.Kill()
+
+ <-ch
+}