rust/library
bors 8c6ce6b91b Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE`

When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program

```rust
fn main() { loop { println!("hello world"); } }
```

will print an error if used with a short-lived pipe, e.g.

    % ./main | head -n 1
    hello world
    thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

by enabling `#[unix_sigpipe = "sig_dfl"]` like this

```rust
#![feature(unix_sigpipe)]
#[unix_sigpipe = "sig_dfl"]
fn main() { loop { println!("hello world"); } }
```

there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately:

    % ./main | head -n 1
    hello world

The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`.

With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`.

See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself

See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02 21:08:08 +00:00
..
alloc Auto merge of #100707 - dzvon:fix-typo, r=davidtwco 2022-09-01 05:39:58 +00:00
backtrace@4e5a3f7292 update libbacktrace 2022-05-20 09:30:26 +02:00
core Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc 2022-09-02 11:34:46 +02:00
panic_abort Update comment about personalities in panic_abort 2022-08-23 16:12:58 +08:00
panic_unwind Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum 2022-08-28 04:16:29 +00:00
portable-simd Fix a bunch of typo 2022-08-31 18:24:55 +08:00
proc_macro proc_macro/bridge: send diagnostics over the bridge as a struct 2022-08-06 15:49:43 -04:00
profiler_builtins Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rtstartup Remove custom frame info registration on i686-pc-windows-gnu 2022-08-23 16:12:58 +08:00
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett 2022-09-02 21:08:08 +00:00
stdarch@42df7394d3 Update stdarch submodule 2022-08-23 16:24:59 +02:00
test test: skip terminfo parsing in Miri 2022-08-07 11:56:12 -04:00
unwind unwind: don't build dependency when building for Miri 2022-08-15 12:54:12 -04:00