-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: signal handling: async signals should forward to existing C handlers by default #19465
Comments
You mention When I wrote the os/signal docs, the intent was that in a Go program (as opposed to Go code built with I think you are suggesting that we should extend the signal handling for a Go program as follows: if a C signal handler for SIG is installed before the Go runtime is initialized, and if This isn't a case where I see an obvious right choice. |
You're correct: if I take out the
Yep, your description looks like what I had in mind.
It's not obvious to me either. I would argue that any "reasonable" C handler for I would be surprised to see interesting early-constructor handlers for I'm not at all sure what we should do for asynchronous delivery of signals that are normally synchronous ( |
runtime.sigfwdgo
currently includes this snippet, intended to ignore signals per the documented behavior of os/signal:handlingSig[sig]
is set for all of the signals that theos/signal
package cares about any timesignal.Notify
is called for any signal.That results in signals intended for C handlers (such as
SIGABRT
) being dropped, which is arguably incorrect for programs which may include C handlers for those signals.For example, in the program below we register an early C handler for
SIGUSR1
and a Go handler forSIGUSR2
, then signal the program withSIGUSR1
(in a way that happens to ensure the signal is delivered to a thread in a Go stack frame, to make the program more deterministic).Since there is a C handler for the signal and no corresponding
signal.Notify
call for that signal,sigfwdgo
arguably ought to forwardSIGUSR1
to the C handler.Instead, it returns without forwarding, the handler drops through to
runtime.sighandler
, and the signal is ignored.src/asyncsig/asyncsig.go:
The text was updated successfully, but these errors were encountered: