From a7d2b4d7cef3bf3107c6cf9725cd1c6151cf18d4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 18 Dec 2015 15:29:51 -0800 Subject: runtime: disable a signal by restoring the original disposition Fixes #13034. Fixes #13042. Update #9896. Change-Id: I189f381090223dd07086848aac2d69d2c00d80c4 Reviewed-on: https://go-review.googlesource.com/18062 Reviewed-by: Russ Cox --- src/runtime/runtime2.go | 1 - src/runtime/signal1_unix.go | 13 +++---------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 9549d1f531..c357f6e6d5 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -482,7 +482,6 @@ const ( _SigPanic // if the signal is from the kernel, panic _SigDefault // if the signal isn't explicitly requested, don't monitor it _SigHandling // our signal handler is registered - _SigIgnored // the signal was ignored before we registered for it _SigGoExit // cause all runtime procs to exit (only used on Plan 9). _SigSetStack // add SA_ONSTACK to libc handler _SigUnblock // unblocked in minit diff --git a/src/runtime/signal1_unix.go b/src/runtime/signal1_unix.go index 3bb3ed8312..468d6f6946 100644 --- a/src/runtime/signal1_unix.go +++ b/src/runtime/signal1_unix.go @@ -49,13 +49,13 @@ func initsig() { continue } fwdSig[i] = getsig(i) + // For some signals, we respect an inherited SIG_IGN handler // rather than insist on installing our own default handler. // Even these signals can be fetched using the os/signal package. switch i { case _SIGHUP, _SIGINT: - if getsig(i) == _SIG_IGN { - t.flags = _SigNotify | _SigIgnored + if fwdSig[i] == _SIG_IGN { continue } } @@ -90,9 +90,6 @@ func sigenable(sig uint32) { <-maskUpdatedChan if t.flags&_SigHandling == 0 { t.flags |= _SigHandling - if getsig(int32(sig)) == _SIG_IGN { - t.flags |= _SigIgnored - } setsig(int32(sig), funcPC(sighandler), true) } } @@ -110,11 +107,7 @@ func sigdisable(sig uint32) { <-maskUpdatedChan if t.flags&_SigHandling != 0 { t.flags &^= _SigHandling - if t.flags&_SigIgnored != 0 { - setsig(int32(sig), _SIG_IGN, true) - } else { - setsig(int32(sig), _SIG_DFL, true) - } + setsig(int32(sig), fwdSig[sig], true) } } } -- cgit v1.3-5-g9baa