Change information
Commit message:
os/signal: completely ignore bogus signals
signal.Notify should ignore bogus signals (syscall.Signals with invalid
signal numbers). Ignoring means Notify/Stop/Reset all work fine, but the
channel will never receive any events.
Today, Stop hangs if Notify has only ever been called with bogus signals
because Stop assumes that runtime.signal_recv is running if a handler is
present. Notify unconditionally registers the handler, but only starts
signal_recv if the signal was valid.
Address this by avoiding registering the handler at all if the signal is
bogus.
We additionally add a bogus signal check to cancel (used by
Ignore/Reset). Currently those are calling into the runtime
signal_ignore and signal_disable, which do ignore bogus signals, but is
now inconsistent with the rest of the package.
For #77076.
Change-Id: I6a6a636c27c41a158e203bbf470be5f1f3f631bd
Files:
- M src/os/signal/signal.go
- A src/runtime/signal_test.go
- A src/runtime/testdata/testprog/signal_bogus.go
Change size: M
Delta: 3 files changed, 73 insertions(+), 6 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Alex Brainman, +2 by Cherry Mui
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI