File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,9 @@ func (p *Process) signal(sig Signal) error {
103
103
}
104
104
105
105
func (p * Process ) pidSignal (s syscall.Signal ) error {
106
+ if p .Pid == pidReleased {
107
+ return errors .New ("os: process already released" )
108
+ }
106
109
if p .Pid == pidUnset {
107
110
return errors .New ("os: process not initialized" )
108
111
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ func TestProcessAlreadyDone(t *testing.T) {
40
40
// EINVAL (see waitid in usr/src/uts/common/os/exit.c in
41
41
// illumos). This is configurable via sysconf(_SC_MAXPID), but
42
42
// we'll just take the default.
43
- pid = 30000 - 1
43
+ pid = 30000 - 1
44
44
}
45
45
46
46
p , err := FindProcess (pid )
@@ -76,3 +76,14 @@ func TestUNIXProcessAlive(t *testing.T) {
76
76
t .Errorf ("OS reported error for running process: %v" , err )
77
77
}
78
78
}
79
+
80
+ func TestProcessBadPID (t * testing.T ) {
81
+ p , err := FindProcess (- 1 )
82
+ if err != nil {
83
+ t .Fatalf ("unexpected FindProcess error: %v" , err )
84
+ }
85
+ err = p .Signal (syscall .Signal (0 ))
86
+ if err == nil {
87
+ t .Error ("p.Signal succeeded unexpectedly" )
88
+ }
89
+ }
You can’t perform that action at this time.
0 commit comments