process_unix::do_exec should reset the signal mask to its value on startup, not clear it #39185
Labels
A-process
Area: `std::process` and `std::env`
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The Unix implementation of
process::spawn
(specifically,do_exec
insys/unix/process/process_unix.rs
) contains logic to restore the signal mask to the default in child processes...Completely clearing the signal mask here is subtly wrong. It should instead be restored to whatever it was when the parent process started up. Certain standard shell utilities — the best-known is
nohup
— deliberately start a process with some signals already masked, and expect that those settings will be inherited by any further subprocesses.For the same reason, the handler for
SIGPIPE
should be reset not toSIG_DFL
, but to whichever ofSIG_DFL
orSIG_IGN
it was before libstd ignored it.(In order to make it possible to implement such utilities in Rust, the ideal resolution here would involve adding
mask_signals
andignore_signals
knobs tounix::process::CommandExt
, and document that the defaults for these are whatever was observed on process startup. But I don't see a clean way to do that without a lot more support for signals in general in libstd, maybe more than is properly in scope.)The text was updated successfully, but these errors were encountered: