You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers
Change process spawning to inherit the parent's signal mask by default
Previously, the signal mask was always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked for all transitive processes.
With this change, the default behavior changes to inherit the signal mask.
This also changes the signal disposition for `SIGPIPE` to only be changed if the `#[unix_sigpipe]` attribute isn't set.
Copy file name to clipboardexpand all lines: src/doc/unstable-book/src/language-features/unix-sigpipe.md
+9-1
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ hello world
36
36
37
37
Set the `SIGPIPE` handler to `SIG_IGN` before invoking `fn main()`. This will result in `ErrorKind::BrokenPipe` errors if you program tries to write to a closed pipe. This is normally what you want if you for example write socket servers, socket clients, or pipe peers.
38
38
39
-
This is what libstd has done by default since 2014. Omitting `#[unix_sigpipe = "..."]` is the same as having `#[unix_sigpipe = "sig_ign"]`.
39
+
This is what libstd has done by default since 2014. (However, see the note on child processes below.)
40
40
41
41
### Example
42
42
@@ -52,3 +52,11 @@ hello world
52
52
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
53
53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
54
54
```
55
+
56
+
### Note on child processes
57
+
58
+
When spawning child processes, the legacy Rust behavior if `#[unix_sigpipe]` is not specified is to
59
+
reset `SIGPIPE` to `SIG_DFL`.
60
+
61
+
If `#[unix_sigpipe = "..."]` is specified, no matter what its value is, the signal disposition of
62
+
`SIGPIPE` is no longer reset. This means that the child inherits the parent's `SIGPIPE` behavior.
0 commit comments