From c492355aa5282522f8653a4517506a9c0be31164 Mon Sep 17 00:00:00 2001 From: Ralf Sager Date: Mon, 31 Jan 2022 23:09:26 +0100 Subject: fix error handling for pthread_sigmask(3) Errors from pthread_sigmask(3) were handled using cvt(), which expects a return value of -1 on error and uses errno. However, pthread_sigmask(3) returns 0 on success and an error number otherwise. Fix it by replacing cvt() with cvt_nz(). --- library/std/src/sys/unix/process/process_unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'library/std/src/sys/unix/process/process_unix.rs') diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 3bf1493f3b8..82f6b5ce519 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -279,7 +279,7 @@ impl Command { stdio: ChildPipes, maybe_envp: Option<&CStringArray>, ) -> Result { - use crate::sys::{self, cvt_r}; + use crate::sys::{self, cvt_nz, cvt_r}; if let Some(fd) = stdio.stdin.fd() { cvt_r(|| libc::dup2(fd, libc::STDIN_FILENO))?; @@ -333,7 +333,7 @@ impl Command { // we're about to run. let mut set = MaybeUninit::::uninit(); cvt(sigemptyset(set.as_mut_ptr()))?; - cvt(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), ptr::null_mut()))?; + cvt_nz(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), ptr::null_mut()))?; #[cfg(target_os = "android")] // see issue #88585 { -- cgit 1.4.1-3-g733a5 From e6aafbc70781bd346c6363a166641baa4f224a14 Mon Sep 17 00:00:00 2001 From: Ralf Sager Date: Sun, 17 Apr 2022 09:42:15 +0200 Subject: move import to fix warning with emscripten target --- library/std/src/sys/unix/process/process_unix.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'library/std/src/sys/unix/process/process_unix.rs') diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 82f6b5ce519..84c5aa8a81b 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -279,7 +279,7 @@ impl Command { stdio: ChildPipes, maybe_envp: Option<&CStringArray>, ) -> Result { - use crate::sys::{self, cvt_nz, cvt_r}; + use crate::sys::{self, cvt_r}; if let Some(fd) = stdio.stdin.fd() { cvt_r(|| libc::dup2(fd, libc::STDIN_FILENO))?; @@ -324,6 +324,7 @@ impl Command { #[cfg(not(target_os = "emscripten"))] { use crate::mem::MaybeUninit; + use crate::sys::cvt_nz; // Reset signal handling so the child process starts in a // standardized state. libstd ignores SIGPIPE, and signal-handling // libraries often set a mask. Child processes inherit ignored -- cgit 1.4.1-3-g733a5