1
Fork 0
rust/compiler/rustc_codegen_ssa/src
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
..
back Rollup merge of #100200 - petrochenkov:zgccld2, r=lqd,Mark-Simulacrum 2022-09-02 18:21:59 +02:00
coverageinfo Remove in_band_lifetimes from rustc_codegen_ssa 2021-12-15 00:41:41 -05:00
debuginfo Use enum2<_> instead of enum<_> for Cpp-like debuginfo enum type names. 2022-08-12 10:53:07 +02:00
mir Auto merge of #100958 - mikebenfield:workaround, r=nikic 2022-09-01 10:30:10 +00:00
traits Move the cast_float_to_int fallback code to GCC 2022-08-16 15:46:17 -07:00
base.rs Support #[unix_sigpipe = "inherit|sig_dfl|sig_ign"] on fn main() 2022-08-28 19:46:45 +02:00
common.rs rustc_codegen_ssa: derive copy and clone for various enums 2022-05-25 10:34:35 +02:00
glue.rs use unchecked mul to compute slice sizes 2022-06-14 17:09:07 -04:00
lib.rs Code cleaning 2022-08-25 19:04:00 +02:00
meth.rs Simplify get_trait_ref a bit 2022-08-29 04:19:14 +00:00
mono_item.rs Add codegen for global_asm! sym operands 2022-04-15 14:36:30 +01:00
target_features.rs feat: Target features for 1st group of RISC-V Bitmanip extensions 2022-08-14 12:09:44 +02:00