Repository navigation
Simplify SIGQUIT handling - #11381
Conversation
sholderbach
left a comment
There was a problem hiding this comment.
Sounds like a good call to me based on what we do currently.
Not sure if we should do extra work for non-interactive uses (glibc docs mention the recommendation to dump stuff)
| #[cfg(windows)] | ||
| pub fn get_sig_quit(&self) -> &Option<Arc<AtomicBool>> { | ||
| &None | ||
| } |
There was a problem hiding this comment.
Good call removing that flag as it is never read.
| pub(crate) fn sigquit_protection(engine_state: &mut EngineState) { | ||
| use signal_hook::consts::SIGQUIT; | ||
| let sig_quit = Arc::new(AtomicBool::new(false)); | ||
| signal_hook::flag::register(SIGQUIT, sig_quit.clone()).expect("Error setting SIGQUIT flag"); |
There was a problem hiding this comment.
If I read the signal_hook docs correctly this is a confusingly implicit way of in effect ignoring the default system handler
There was a problem hiding this comment.
Correct, signal_hook::flag::register will prevent the default handler from running and instead sets the AtomicBool to true.
I don't think we have to. A ⮞ bash -c 'sleep 100'
^\Quit: oops, process 'bash' core dumped
Error: nu::shell::external_command
× External command failed
╭─[entry #1:1:1]
1 │ bash -c 'sleep 100'
· ──┬─
· ╰── core dumped
╰────
help: Quit: child process 'bash' core dumpedAnd now with this PR, also nushell: ⮞ ./target/debug/nu -n -c 'sleep 100sec'
^\Quit: oops, process './target/debug/nu' core dumped
Error: nu::shell::external_command
× External command failed
╭─[entry #8:1:1]
1 │ ./target/debug/nu -n -c 'sleep 100sec'
· ────────┬────────
· ╰── core dumped
╰────
help: Quit: child process './target/debug/nu' core dumped |
|
OK, thanks for immediately investigating! From my side I would be fine with landing this as is, as we reasoned about the impact and the testing was non-existent beforehand. |
|
Ok, because we handle signals incorrectly in other places, this PR makes it so that |
|
Let's go with removing the unused flag and correctly setting the mask for interactive mode. |
# Description Simplifies `SIGQUIT` protection to a single `signal` ignore system call. # User-Facing Changes `SIGQUIT` is no longer blocked if nushell is in non-interactive mode (signals should not be blocked in non-interactive mode). Also a breaking API change for `nu_protocol`. # Tests + Formatting Should come after nushell#11178 for testing.
Description
Simplifies
SIGQUITprotection to a singlesignalignore system call.User-Facing Changes
SIGQUITis no longer blocked if nushell is in non-interactive mode (signals should not be blocked in non-interactive mode).Also a breaking API change for
nu_protocol.Tests + Formatting
Should come after #11178 for testing.