"strconv"
"syscall"
"testing"
+ "time"
)
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
+}
case "stderrfail":
fmt.Fprintf(os.Stderr, "some stderr text\n")
os.Exit(1)
+ case "sleep":
+ time.Sleep(3 * time.Second)
+ os.Exit(0)
default:
fmt.Fprintf(os.Stderr, "Unknown command %q\n", cmd)
os.Exit(2)
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build dragonfly nacl netbsd openbsd solaris
+// +build darwin dragonfly nacl netbsd openbsd solaris
package os
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin linux
+// We used to used this code for Darwin, but according to issue #19314
+// waitid returns if the process is stopped, even when using WEXITED.
+
+// +build linux
package os