Skip to content

Do not block signals for child processes - #11402

Merged
fdncred merged 28 commits into
nushell:mainfrom
IanManske:reset-signal-handlers
Jan 15, 2024
Merged

fdncred merged 28 commits into
nushell:mainfrom
IanManske:reset-signal-handlers

Conversation

@IanManske

@IanManske IanManske commented Dec 22, 2023 •

Copy link
Copy Markdown
Member

Description / User-Facing Changes

Signals are no longer blocked for child processes launched from both interactive and non-interactive mode. The only exception is that SIGTSTP, SIGTTIN, and SIGTTOU remain blocked for child processes launched only from interactive mode. This is to help prevent nushell from getting into an unrecoverable state, since we don't support background jobs. Anyways, this fully fixes #9026.

Other Notes

  • Needs Rust version >= 1.66 for a fix in std::process::Command::spawn, but it looks our current Rust version is way above this.

  • Uses sigaction instead of signal, since the behavior of signal can apparently differ across systems. Also, the sigaction man page says:

    The sigaction() function supersedes the signal() function, and should be used in preference.

    Additionally, using both sigaction and signal is not recommended. Since we were already using sigaction in some places (and possibly some of our dependencies as well), this PR replaces all usages of signal.

Tests

Might want to wait for #11178 for testing.

@IanManske
IanManske marked this pull request as ready for review January 12, 2024 15:42
@fdncred
fdncred merged commit 9249865 into nushell:main Jan 15, 2024
@fdncred

fdncred commented Jan 15, 2024

Copy link
Copy Markdown
Contributor

As discussed on discord. Thanks!

@kubouch kubouch added the notes:fixes Noted in "Bug fixes" section label Jan 17, 2024
@rgwood

rgwood commented Jan 19, 2024

Copy link
Copy Markdown
Contributor

Thank you - this is a tricky area to get right and I really appreciate people working on it!

@IanManske
IanManske deleted the reset-signal-handlers branch February 2, 2024 21:19
@hustcer hustcer added this to the v0.90.0 milestone Feb 3, 2024
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
# Description / User-Facing Changes
Signals are no longer blocked for child processes launched from both
interactive and non-interactive mode. The only exception is that
`SIGTSTP`, `SIGTTIN`, and `SIGTTOU` remain blocked for child processes
launched only from **interactive** mode. This is to help prevent nushell
from getting into an unrecoverable state, since we don't support
background jobs. Anyways, this fully fixes nushell#9026.

# Other Notes
- Needs Rust version `>= 1.66` for a fix in
`std::process::Command::spawn`, but it looks our current Rust version is
way above this.
- Uses `sigaction` instead of `signal`, since the behavior of `signal`
can apparently differ across systems. Also, the `sigaction` man page
says:
> The sigaction() function supersedes the signal() function, and should
be used in preference.

Additionally, using both `sigaction` and `signal` is not recommended.
Since we were already using `sigaction` in some places (and possibly
some of our dependencies as well), this PR replaces all usages of
`signal`.

# Tests
Might want to wait for nushell#11178 for testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nushell shouldn't do anything job control-y when not in interactive mode

5 participants