Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go1.10
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
darwin amd64
What did you do?
By default on POSIX, the SIGUSR1 and SIGUSR2 asynchronous signals terminate the process when they are received.
Go's documented default for these signals (and others, but these are the ones I'm thinking about today) is to register a handler and take no action when they are received.
This is not unreasonable. However, it's a shame that there is no way to restore POSIX's default behavior of terminating due to the signal: ie, to call sigaction with SIG_DFL so that when the process receives that signal, another process wait()ing on it sees that it died with the SIGUSR1/SIGUSR2. Of course, you can signal.Notify on these signals and do an os.Exit (or syscall.Kill yourself with a more fatal signal), but you can't get SIGUSR1/SIGUSR2 into the exit status.
I noticed this because some of my project's users are running our Go binary indirectly from a Node program managed by https://github.com/remy/nodemon, a popular Node library for restarting programs during development. By default, nodemon sends SIGUSR2 to its child and all of its children as the restarting signal, and it cares specifically whether or not the killed child died due to the signal it sent or now.
(In fact, nodemon doesn't actually care if grandchildren processes which it killed with SIGUSR2 died for that reason, so in practice this issue doesn't matter in the nodemon case, but it highlighted to me that it is impossible to achieve this default POSIX behavior in Go.)
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go1.10
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?darwin amd64
What did you do?
By default on POSIX, the SIGUSR1 and SIGUSR2 asynchronous signals terminate the process when they are received.
Go's documented default for these signals (and others, but these are the ones I'm thinking about today) is to register a handler and take no action when they are received.
This is not unreasonable. However, it's a shame that there is no way to restore POSIX's default behavior of terminating due to the signal: ie, to call sigaction with SIG_DFL so that when the process receives that signal, another process wait()ing on it sees that it died with the SIGUSR1/SIGUSR2. Of course, you can signal.Notify on these signals and do an os.Exit (or syscall.Kill yourself with a more fatal signal), but you can't get SIGUSR1/SIGUSR2 into the exit status.
I noticed this because some of my project's users are running our Go binary indirectly from a Node program managed by https://github.com/remy/nodemon, a popular Node library for restarting programs during development. By default, nodemon sends SIGUSR2 to its child and all of its children as the restarting signal, and it cares specifically whether or not the killed child died due to the signal it sent or now.
(In fact, nodemon doesn't actually care if grandchildren processes which it killed with SIGUSR2 died for that reason, so in practice this issue doesn't matter in the nodemon case, but it highlighted to me that it is impossible to achieve this default POSIX behavior in Go.)