Skip to content

Commit f1c8acc

Browse files
committed
Use libc::sigaction() instead of sys::signal() to prevent a deadlock
1 parent 497ee32 commit f1c8acc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

library/std/src/sys/unix/process/process_unix.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,9 @@ impl Command {
333333
let mut set = MaybeUninit::<libc::sigset_t>::uninit();
334334
cvt(sigemptyset(set.as_mut_ptr()))?;
335335
cvt(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), ptr::null_mut()))?;
336-
let ret = sys::signal(libc::SIGPIPE, libc::SIG_DFL);
337-
if ret == libc::SIG_ERR {
338-
return Err(io::Error::last_os_error());
339-
}
336+
let mut action: libc::sigaction = mem::zeroed();
337+
action.sa_sigaction = libc::SIG_DFL;
338+
cvt(libc::sigaction(libc::SIGPIPE, &action as *const _, ptr::null_mut()))?;
340339
}
341340

342341
for callback in self.get_closures().iter_mut() {

0 commit comments

Comments
 (0)