mirror of
https://github.com/golang/go.git
synced 2025-11-08 04:31:01 +00:00
os/signal: selective signal handling
Restore package os/signal, with new API: Notify replaces Incoming, allowing clients to ask for certain signals only. Also, signals go to everyone who asks, not just one client. This could plausibly move into package os now that there are no magic side effects as a result of the import. Update runtime for new API: move common Unix signal handling code into signal_unix.c. (It's so easy to do this now that we don't have to edit Makefiles!) Tested on darwin,linux 386,amd64. Fixes #1266. R=r, dsymonds, bradfitz, iant, borman CC=golang-dev https://golang.org/cl/3749041
This commit is contained in:
parent
cdd7e02583
commit
35586f718c
61 changed files with 1216 additions and 1266 deletions
|
|
@ -57,7 +57,11 @@ func (p *Process) Signal(sig Signal) error {
|
|||
if p.done {
|
||||
return errors.New("os: process already finished")
|
||||
}
|
||||
if e := syscall.Kill(p.Pid, int(sig.(UnixSignal))); e != nil {
|
||||
s, ok := sig.(syscall.Signal)
|
||||
if !ok {
|
||||
return errors.New("os: unsupported signal type")
|
||||
}
|
||||
if e := syscall.Kill(p.Pid, s); e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue