Skip to content

Commit 397c134

Browse files
authored
Rollup merge of rust-lang#93530 - anonion0:pthread_sigmask_fix, r=kennytm
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()`.
2 parents e7575f9 + c492355 commit 397c134

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

library/std/src/sys/unix/process/process_common/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
use crate::ffi::OsStr;
44
use crate::mem;
55
use crate::ptr;
6-
use crate::sys::cvt;
6+
use crate::sys::{cvt, cvt_nz};
77

88
macro_rules! t {
99
($e:expr) => {
@@ -39,7 +39,7 @@ fn test_process_mask() {
3939
let mut old_set = mem::MaybeUninit::<libc::sigset_t>::uninit();
4040
t!(cvt(sigemptyset(set.as_mut_ptr())));
4141
t!(cvt(sigaddset(set.as_mut_ptr(), libc::SIGINT)));
42-
t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), old_set.as_mut_ptr())));
42+
t!(cvt_nz(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), old_set.as_mut_ptr())));
4343

4444
cmd.stdin(Stdio::MakePipe);
4545
cmd.stdout(Stdio::MakePipe);
@@ -48,7 +48,7 @@ fn test_process_mask() {
4848
let stdin_write = pipes.stdin.take().unwrap();
4949
let stdout_read = pipes.stdout.take().unwrap();
5050

51-
t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, old_set.as_ptr(), ptr::null_mut())));
51+
t!(cvt_nz(libc::pthread_sigmask(libc::SIG_SETMASK, old_set.as_ptr(), ptr::null_mut())));
5252

5353
t!(cvt(libc::kill(cat.id() as libc::pid_t, libc::SIGINT)));
5454
// We need to wait until SIGINT is definitely delivered. The

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl Command {
279279
stdio: ChildPipes,
280280
maybe_envp: Option<&CStringArray>,
281281
) -> Result<!, io::Error> {
282-
use crate::sys::{self, cvt_r};
282+
use crate::sys::{self, cvt_nz, cvt_r};
283283

284284
if let Some(fd) = stdio.stdin.fd() {
285285
cvt_r(|| libc::dup2(fd, libc::STDIN_FILENO))?;
@@ -337,7 +337,7 @@ impl Command {
337337
// we're about to run.
338338
let mut set = MaybeUninit::<libc::sigset_t>::uninit();
339339
cvt(sigemptyset(set.as_mut_ptr()))?;
340-
cvt(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), ptr::null_mut()))?;
340+
cvt_nz(libc::pthread_sigmask(libc::SIG_SETMASK, set.as_ptr(), ptr::null_mut()))?;
341341

342342
#[cfg(target_os = "android")] // see issue #88585
343343
{

0 commit comments

Comments
 (0)