diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-05-29 19:03:06 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-05 13:55:11 -0700 |
| commit | 760b93adc0976121149105db19acf2ad5f631e5d (patch) | |
| tree | 6c20eba4139bfdd332187122315f7802367d7d6f /src/libnative | |
| parent | 6a585375a01b7c6b52ad93f764220bcb18027ef6 (diff) | |
Fallout from the libcollections movement
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/process.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index cddae53fa42..4b75e1b7359 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -921,19 +921,22 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<p::ProcessExit> { // Register a new SIGCHLD handler, returning the reading half of the // self-pipe plus the old handler registered (return value of sigaction). + // + // Be sure to set up the self-pipe first because as soon as we reigster a + // handler we're going to start receiving signals. fn register_sigchld() -> (libc::c_int, c::sigaction) { unsafe { - let mut old: c::sigaction = mem::zeroed(); - let mut new: c::sigaction = mem::zeroed(); - new.sa_handler = sigchld_handler; - new.sa_flags = c::SA_NOCLDSTOP; - assert_eq!(c::sigaction(c::SIGCHLD, &new, &mut old), 0); - let mut pipes = [0, ..2]; assert_eq!(libc::pipe(pipes.as_mut_ptr()), 0); util::set_nonblocking(pipes[0], true).unwrap(); util::set_nonblocking(pipes[1], true).unwrap(); WRITE_FD = pipes[1]; + + let mut old: c::sigaction = mem::zeroed(); + let mut new: c::sigaction = mem::zeroed(); + new.sa_handler = sigchld_handler; + new.sa_flags = c::SA_NOCLDSTOP; + assert_eq!(c::sigaction(c::SIGCHLD, &new, &mut old), 0); (pipes[0], old) } } |
