diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-10-20 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-10-20 00:00:00 +0000 |
| commit | 21c29b1e954d494026b07241aa8365837d5ecfdb (patch) | |
| tree | ae5bc05e490ce1527af198a8678ea32680bfe417 /library/std/src/sys/unix/process/process_unix.rs | |
| parent | a85e94927622665a9e9022de0d33a890a2e32d43 (diff) | |
| download | rust-21c29b1e954d494026b07241aa8365837d5ecfdb.tar.gz rust-21c29b1e954d494026b07241aa8365837d5ecfdb.zip | |
Check that pthread mutex initialization succeeded
If pthread mutex initialization fails, the failure will go unnoticed unless debug assertions are enabled. Any subsequent use of mutex will also silently fail, since return values from lock & unlock operations are similarly checked only through debug assertions. In some implementations the mutex initialization requires a memory allocation and so it does fail in practice. Check that initialization succeeds to ensure that mutex guarantees mutual exclusion.
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index b05319c89e8..a590c744356 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -281,7 +281,7 @@ impl Command { envp: Option<&CStringArray>, ) -> io::Result<Option<Process>> { use crate::mem::MaybeUninit; - use crate::sys; + use crate::sys::{self, cvt_nz}; if self.get_gid().is_some() || self.get_uid().is_some() @@ -343,10 +343,6 @@ impl Command { } } - fn cvt_nz(error: libc::c_int) -> io::Result<()> { - if error == 0 { Ok(()) } else { Err(io::Error::from_raw_os_error(error)) } - } - unsafe { let mut attrs = MaybeUninit::uninit(); cvt_nz(libc::posix_spawnattr_init(attrs.as_mut_ptr()))?; |
