mirror of
https://github.com/golang/go.git
synced 2025-11-08 12:41:02 +00:00
os: don't permit Process.Signal after a successful Wait
R=dsymonds, rsc CC=golang-dev https://golang.org/cl/4689043
This commit is contained in:
parent
d1f4e0d14e
commit
d53385fd0c
4 changed files with 20 additions and 2 deletions
|
|
@ -38,6 +38,9 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
|
|||
if e != 0 {
|
||||
return nil, NewSyscallError("wait", e)
|
||||
}
|
||||
if options&WSTOPPED == 0 {
|
||||
p.done = true
|
||||
}
|
||||
w = new(Waitmsg)
|
||||
w.Pid = pid1
|
||||
w.WaitStatus = status
|
||||
|
|
@ -47,6 +50,9 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
|
|||
|
||||
// Signal sends a signal to the Process.
|
||||
func (p *Process) Signal(sig Signal) Error {
|
||||
if p.done {
|
||||
return NewError("os: process already finished")
|
||||
}
|
||||
if e := syscall.Kill(p.Pid, int(sig.(UnixSignal))); e != 0 {
|
||||
return Errno(e)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue