summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/pid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/pid.rs')
-rw-r--r--vendor/rustix/src/pid.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/vendor/rustix/src/pid.rs b/vendor/rustix/src/pid.rs
index 1b1da6521..3911e4c7a 100644
--- a/vendor/rustix/src/pid.rs
+++ b/vendor/rustix/src/pid.rs
@@ -1,3 +1,5 @@
+//! The `Pid` type.
+
#![allow(unsafe_code)]
use crate::backend::c;
@@ -17,21 +19,21 @@ pub struct Pid(NonZeroI32);
impl Pid {
/// A `Pid` corresponding to the init process (pid 1).
- pub const INIT: Self = Self(
- // SAFETY: One is non-zero.
- unsafe { NonZeroI32::new_unchecked(1) },
- );
+ pub const INIT: Self = Self(match NonZeroI32::new(1) {
+ Some(n) => n,
+ None => panic!("unreachable"),
+ });
/// Converts a `RawPid` into a `Pid`.
///
/// Returns `Some` for strictly positive `RawPid`s. Otherwise, returns
/// `None`.
///
- /// This is always safe because a `Pid` is a number without any guarantees
- /// for the kernel. Non-child `Pid`s are always racy for any syscalls,
- /// but can only cause logic errors. If you want race-free access or
- /// control to non-child processes, please consider other mechanisms
- /// like [pidfd] on Linux.
+ /// This is safe because a `Pid` is a number without any guarantees for the
+ /// kernel. Non-child `Pid`s are always racy for any syscalls, but can only
+ /// cause logic errors. If you want race-free access to or control of
+ /// non-child processes, please consider other mechanisms like [pidfd] on
+ /// Linux.
///
/// [pidfd]: https://man7.org/linux/man-pages/man2/pidfd_open.2.html
#[inline]