[go] os/signal: completely ignore bogus signals

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Feb 24, 2026, 1:27:10 PM (14 hours ago) Feb 24
to Michael Pratt, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alex Brainman, Cherry Mui, Michael Knyszek, golang-co...@googlegroups.com

Gopher Robot submitted the change

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
Reviewed-by: Cherry Mui <cher...@google.com>
Reviewed-by: Alex Brainman <alex.b...@gmail.com>
Auto-Submit: Michael Pratt <mpr...@google.com>
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:
  • requirement satisfiedCode-Review: +2 by Alex Brainman, +2 by Cherry Mui
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I6a6a636c27c41a158e203bbf470be5f1f3f631bd
Gerrit-Change-Number: 735040
Gerrit-PatchSet: 4
Gerrit-Owner: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages