-
Notifications
You must be signed in to change notification settings - Fork 79
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
Check for SIGHUP #78
Check for SIGHUP #78
Conversation
src/platform/unix/mod.rs
Outdated
match signal::sigaction(signal::Signal::SIGHUP, &new_action) { | ||
Ok(_) => {} | ||
Err(e) => { | ||
signal::sigaction(signal::Signal::SIGINT, &_old).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old value for SIGTERM should be reverted in this cleanup function. Also, the variable _old
should be named old
now as it is being used. Maybe assign current _old
to sigint_old
and introduce sigterm_old
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a change. Is that maybe what you have in mind?
I took another look at https://en.wikipedia.org/wiki/Signal_(IPC)#POSIX_signals and found this other signal:
This should probably be handled as well to ensure a graceful termination whenever possible. Do you see anything else that might be worth checking for on the article? Maybe |
I don't think |
@Detegr I made some changes and tested it. Do you mind taking a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Could you rebase the branch to only have a single commit that does the change?
Done. |
If you have the
termination
feature enabled and close the terminal (its window) with the X button,SIGHUP
is sent to the process butctrlc
doesn't handle it so no graceful shutdown is done in that case but I would expect thetermination
feature to be able to detect that because pressing the X button to terminate an application is definitely a common kind of termination. Also, I believe on Windows this already works because when the window is X-ed,CTRL_CLOSE_EVENT
is sent whichctrlc
seems to handle. This means on Windows, the handler is invoked on X but on Linux (and very likely macOS), it is not. So this fixes inconsistent behavior.