mitchellh / panicwrap

panicwrap is a Go library for catching and handling panics in Go applications.
https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc
MIT License
444 stars 66 forks source link

Forward SIGTERM on UNIX. #15

Closed mildred closed 7 years ago

mildred commented 7 years ago

SIGINT is generally sent to all processes connected to the virtual terminal when typing Ctrl-C. SIGTERM is generally sent to a single process. In that case, it is wise not to ignore that signal but to forward it to the child process instead to give it the opportunity to handle it.

This is required for correct handling of SIGTERM inside terraform, see hashicorp/terraform#10459. When SIGTERN is sent to the parent process, ignoring the signal won't help, it must be forwarded.

This PR contains a default that depends on the platform for the list of forwarded signals. On UNIX it contains SIGTERM and on Windows, nothing. Possibly the default could be no signal at all by default, and let the panicwrap user choose on its own.

mitchellh commented 7 years ago

Hi, yes, you already opened this issue once before for #14. I'll close for the same reason (see #14).

mildred commented 7 years ago

No, this is not the same, #14 was about ignoring SIGTERM, this one is about forwarding SIGTERM.

mildred commented 7 years ago

I used the same branch for both PR, but they are different. #14 is about ignoring SIGTERM (which was incorrect) and this PR is about forwarding SIGTERM.

mitchellh commented 7 years ago

Ah interesting, I didn't realize that SIGTERM isn't sent to all processes. That is interesting. I'll reopen this.

mitchellh commented 7 years ago

Hm, I can't reopen this PR for some reason. I'll take a look again.