rust/library/std/src/sys/unix
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
..
fd I/O safety. 2021-08-19 12:02:39 -07:00
kernel_copy add test for failing io::copy specialization 2021-02-22 21:41:32 +01:00
locks Fix a bunch of typo 2022-08-31 18:24:55 +08:00
os Refactor weak symbols in std::sys::unix 2021-11-12 15:25:16 -08:00
os_str Expose Utf8Lossy as Utf8Chunks 2022-08-20 12:49:20 -04:00
process Use posix_spawn for absolute paths on macOS 2022-08-28 19:31:09 -07:00
alloc.rs Horizon OS STD support 2022-06-13 20:44:39 -07:00
android.rs Refactor weak symbols in std::sys::unix 2021-11-12 15:25:16 -08:00
args.rs Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
cmath.rs Reuse unix::cmath 2021-04-28 14:25:04 +02:00
env.rs Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
fd.rs Address reviewer comments 2022-08-18 10:34:40 +01:00
fs.rs Rollup merge of #97015 - nrc:read-buf-cursor, r=Mark-Simulacrum 2022-08-28 09:35:11 +02:00
futex.rs std: panic instead of deadlocking in mutex implementation on Fuchsia 2022-07-18 10:56:10 +02:00
io.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
kernel_copy.rs Use Rust 2021 prelude in std itself. 2022-05-09 11:12:32 +02:00
l4re.rs Use Rust 2021 prelude in std itself. 2022-05-09 11:12:32 +02:00
memchr.rs mark FIXMES for all the places found that are probably offset_from 2022-03-29 20:18:28 -04:00
mod.rs unix_sigpipe: Make sigpipe param docs long-form 2022-09-01 06:45:04 +02:00
net.rs Rollup merge of #96334 - devnexen:socket_mark, r=dtolnay 2022-08-29 06:34:42 +02:00
os_str.rs Expose Utf8Lossy as Utf8Chunks 2022-08-20 12:49:20 -04:00
os.rs Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
path.rs Unix path::absolute: Fix leading "." component 2022-03-05 17:57:12 +00:00
pipe.rs I/O safety. 2021-08-19 12:02:39 -07:00
rand.rs Use getentropy when possible on all Apple platforms 2022-08-25 15:55:04 -05:00
stack_overflow.rs Update libc to 0.2.121 2022-04-05 11:22:32 -05:00
stdio.rs Implement stabilization of #[feature(io_safety)]. 2022-06-14 14:46:22 -07:00
thread_local_dtor.rs Enable thread_local_dtor on horizon OS 2022-06-13 20:45:24 -07:00
thread_local_key.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_parker.rs Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc 2022-07-20 16:17:17 +05:30
thread.rs linux: Use pthread_setname_np instead of prctl 2022-08-08 13:27:09 -07:00
time.rs Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
weak.rs Replace sys/unix/weak AtomicUsize with AtomicPtr 2022-04-17 23:33:56 -05:00