File tree 4 files changed +46
-2
lines changed
4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"strconv"
12
12
"syscall"
13
13
"testing"
14
+ "time"
14
15
)
15
16
16
17
func TestCredentialNoSetGroups (t * testing.T ) {
@@ -43,3 +44,40 @@ func TestCredentialNoSetGroups(t *testing.T) {
43
44
t .Errorf ("Failed to run command: %v" , err )
44
45
}
45
46
}
47
+
48
+ // For issue #19314: make sure that SIGSTOP does not cause the process
49
+ // to appear done.
50
+ func TestWaitid (t * testing.T ) {
51
+ t .Parallel ()
52
+
53
+ cmd := helperCommand (t , "sleep" )
54
+ if err := cmd .Start (); err != nil {
55
+ t .Fatal (err )
56
+ }
57
+
58
+ // The sleeps here are unnecessary in the sense that the test
59
+ // should still pass, but they are useful to make it more
60
+ // likely that we are testing the expected state of the child.
61
+ time .Sleep (100 * time .Millisecond )
62
+
63
+ if err := cmd .Process .Signal (syscall .SIGSTOP ); err != nil {
64
+ cmd .Process .Kill ()
65
+ t .Fatal (err )
66
+ }
67
+
68
+ ch := make (chan error )
69
+ go func () {
70
+ ch <- cmd .Wait ()
71
+ }()
72
+
73
+ time .Sleep (100 * time .Millisecond )
74
+
75
+ if err := cmd .Process .Signal (syscall .SIGCONT ); err != nil {
76
+ t .Error (err )
77
+ syscall .Kill (cmd .Process .Pid , syscall .SIGCONT )
78
+ }
79
+
80
+ cmd .Process .Kill ()
81
+
82
+ <- ch
83
+ }
Original file line number Diff line number Diff line change @@ -868,6 +868,9 @@ func TestHelperProcess(*testing.T) {
868
868
case "stderrfail" :
869
869
fmt .Fprintf (os .Stderr , "some stderr text\n " )
870
870
os .Exit (1 )
871
+ case "sleep" :
872
+ time .Sleep (3 * time .Second )
873
+ os .Exit (0 )
871
874
default :
872
875
fmt .Fprintf (os .Stderr , "Unknown command %q\n " , cmd )
873
876
os .Exit (2 )
Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- // +build dragonfly nacl netbsd openbsd solaris
5
+ // +build darwin dragonfly nacl netbsd openbsd solaris
6
6
7
7
package os
8
8
Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- // +build darwin linux
5
+ // We used to used this code for Darwin, but according to issue #19314
6
+ // waitid returns if the process is stopped, even when using WEXITED.
7
+
8
+ // +build linux
6
9
7
10
package os
8
11
You can’t perform that action at this time.
0 commit comments