-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
os/signal: Prevent developers from catching SIGKILL and SIGSTOP #9463
Comments
What should signal.Notify do when asked to notify on an uncatchable signal. The method does not return an error, and panic would be incompatible with existing code which is happy that those signals are uncatchable. |
the channel c just won't receive any notifications, and i think that's enough. |
How about a compile error? It could be the potential problem when developers aren't aware of it. |
That cannot be a compile error. The function is being called with correctly typed arguments. The compiler does not enforce library API usage concerns. In any case, making this an error of any kind is a backwards incompatible change, as was explained by @davecheney and @minux already. Such changes are disallowed by the Go 1 compatibility promise. More in the realm of possibility is adding go vet checks. |
Thanks @cespare and the suggestion is nice 😃 |
It's not a big deal and every developer should know about it actually. But there's alway someone asking the question like "why can't I catch it even though I have add it in |
Issues about the whole Go project should be filed here. |
Refer to https://en.wikipedia.org/wiki/Unix_signal#SIGKILL, we know that SIGKILL and SIGSTOP can't be caught or ignored. So golang should prevent developers from trying to do that.
Now the following code is possible to compile but totally invalid.
The text was updated successfully, but these errors were encountered: