rust/src
bors 4e2a898afc Auto merge of #25784 - geofft:subprocess-signal-masks, r=alexcrichton
UNIX specifies that signal dispositions and masks get inherited to child processes, but in general, programs are not very robust to being started with non-default signal dispositions or to signals being blocked. For example, libstd sets `SIGPIPE` to be ignored, on the grounds that Rust code using libstd will get the `EPIPE` errno and handle it correctly. But shell pipelines are built around the assumption that `SIGPIPE` will have its default behavior of killing the process, so that things like `head` work:

```
geofft@titan:/tmp$ for i in `seq 1 20`; do echo "$i"; done | head -1
1
geofft@titan:/tmp$ cat bash.rs
fn main() {
        std::process::Command::new("bash").status();
}
geofft@titan:/tmp$ ./bash
geofft@titan:/tmp$ for i in `seq 1 20`; do echo "$i"; done | head -1
1
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
[...]
```

Here, `head` is supposed to terminate the input process quietly, but the bash subshell has inherited the ignored disposition of `SIGPIPE` from its Rust grandparent process. So it gets a bunch of `EPIPE`s that it doesn't know what to do with, and treats it as a generic, transient error. You can see similar behavior with `find / | head`, `yes | head`, etc.

This PR resets Rust's `SIGPIPE` handler, as well as any signal mask that may have been set, before spawning a child. Setting a signal mask, and then using a dedicated thread or something like `signalfd` to dequeue signals, is one of two reasonable ways for a library to process signals. See carllerche/mio#16 for more discussion about this approach to signal handling and why it needs a change to `std::process`. The other approach is for the library to set a signal-handling function (`signal()` / `sigaction()`): in that case, dispositions are reset to the default behavior on exec (since the function pointer isn't valid across exec), so we don't have to care about that here.

As part of this PR, I noticed that we had two somewhat-overlapping sets of bindings to signal functionality in `libstd`. One dated to old-IO and probably the old runtime, and was mostly unused. The other is currently used by `stack_overflow.rs`. I consolidated the two bindings into one set, and double-checked them by hand against all supported platforms' headers. This probably means it's safe to enable `stack_overflow.rs` on more targets, but I'm not including such a change in this PR.

r? @alexcrichton
cc @Zoxc for changes to `stack_overflow.rs`
2015-06-22 16:11:38 +00:00
..
compiler-rt@58ab642c30
compiletest Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
doc Auto merge of #26037 - nhowell:plain_js_playpen, r=steveklabnik 2015-06-22 05:23:50 +00:00
driver Unquote all crate names without underscores 2015-03-27 10:58:12 -07:00
error-index-generator diagnostics: Resurrect the Compiler Error Index. 2015-06-20 16:57:40 +10:00
etc Add src/etc/add-authors.sh script for managing the AUTHORS.txt file 2015-06-17 16:32:01 -07:00
grammar Replace usage of String::from_str with String:from 2015-06-08 16:55:35 +02:00
jemalloc@e24a1a025a bumping again to get the updated configure 2015-03-05 12:38:35 +05:30
liballoc Add comment about stabilizing CString::from_ptr 2015-06-17 09:07:17 -07:00
libarena alloc: Split apart the global alloc feature 2015-06-17 09:06:59 -07:00
libbacktrace Reapply rust-specific changes to libbacktrace 2015-04-11 22:30:17 +10:00
libcollections std: Stabilize vec_map::Entry::or_insert{,_with} 2015-06-17 09:07:17 -07:00
libcollectionstest More test fixes and fallout of stability changes 2015-06-17 09:07:17 -07:00
libcore Auto merge of #26450 - rick68:patch-7, r=alexcrichton 2015-06-21 05:18:39 +00:00
libcoretest Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
libflate Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
libfmt_macros libs: Move favicon URLs to HTTPS 2015-05-15 16:04:01 -07:00
libgetopts Removed many pointless calls to *iter() and iter_mut() 2015-06-10 21:14:03 +01:00
libgraphviz collections: Split the collections feature 2015-06-17 09:06:59 -07:00
liblibc liblibc: Fix prototype of functions taking char *const argv[] 2015-06-19 23:34:37 -04:00
liblog More test fixes and fallout of stability changes 2015-06-17 09:07:17 -07:00
librand Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
librbml core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
librustc Make expr_is_lval more robust 2015-06-21 22:31:57 +03:00
librustc_back collections: Split the collections feature 2015-06-17 09:06:59 -07:00
librustc_bitflags Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
librustc_borrowck rustc: remove Repr and UserString. 2015-06-19 01:39:26 +03:00
librustc_data_structures Expand the "givens" set to cover transitive relations. The givens array 2015-06-19 12:22:03 -04:00
librustc_driver Auto merge of #26417 - brson:feature-err, r=steveklabnik 2015-06-20 14:24:19 +00:00
librustc_lint Auto merge of #26417 - brson:feature-err, r=steveklabnik 2015-06-20 14:24:19 +00:00
librustc_llvm Simplify argument forwarding in the various shim generators 2015-06-20 03:35:24 +02:00
librustc_privacy Cleanup: rename middle::ty::sty and its variants. 2015-06-12 11:07:16 -07:00
librustc_resolve rustc_resolve: don't require redundant arguments to resolve_crate. 2015-06-19 01:18:42 +03:00
librustc_trans Make expr_is_lval more robust 2015-06-21 22:31:57 +03:00
librustc_typeck Auto merge of #26394 - arielb1:implement-rfc401-part2, r=nrc 2015-06-22 00:11:00 +00:00
librustc_unicode Fallout in tests and docs from feature renamings 2015-06-17 09:07:16 -07:00
librustdoc Auto merge of #26037 - nhowell:plain_js_playpen, r=steveklabnik 2015-06-22 05:23:50 +00:00
libserialize More test fixes and fallout of stability changes 2015-06-17 09:07:17 -07:00
libstd Fix build on Android API levels below 21 2015-06-22 00:55:42 -04:00
libsyntax Rollup merge of #26452 - michaelsproul:the-second-coming, r=pnkfelix 2015-06-20 21:40:37 +05:30
libterm std: Split the std_misc feature 2015-06-17 09:06:59 -07:00
libtest Auto merge of #26192 - alexcrichton:features-clean, r=aturon 2015-06-18 19:14:52 +00:00
llvm@8cbcdf1b72 rustc: Update LLVM 2015-06-16 22:56:42 -07:00
rt src/rt/arch/i386/morestack.S: call rust_stack_exhausted via plt 2015-06-15 14:56:50 -04:00
rust-installer@8e4f8ea581 updating installer to fix install issues on bitrig 2015-06-18 23:43:46 -07:00
rustbook Auto merge of #26037 - nhowell:plain_js_playpen, r=steveklabnik 2015-06-22 05:23:50 +00:00
rustllvm Auto merge of #26025 - alexcrichton:update-llvm, r=brson 2015-06-17 06:56:15 +00:00
test Auto merge of #25784 - geofft:subprocess-signal-masks, r=alexcrichton 2015-06-22 16:11:38 +00:00
snapshots.txt Register snapshots (2015-05-24 ba0e1cd). 2015-05-27 11:19:02 +03:00