pub struct Pid(/* private fields */);process only.Expand description
pid_t—A non-zero Unix process ID.
This is a pid, and not a pidfd. It is not a file descriptor, and the process it refers to could disappear at any time and be replaced by another, unrelated, process.
On Linux, Pid values are also used to identify threads.
Implementations§
Source§impl Pid
impl Pid
Sourcepub const INIT: Self
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const INIT: Self
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.A Pid corresponding to the init process (pid 1).
Sourcepub const fn from_raw(raw: RawPid) -> Option<Self>
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const fn from_raw(raw: RawPid) -> Option<Self>
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Converts a RawPid into a Pid.
Returns Some for positive values, and None for zero values.
This is safe because a Pid is a number without any guarantees for the
kernel. Non-child Pids 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.
Passing a negative number doesn’t invoke undefined behavior, but it may cause unexpected behavior.
Sourcepub const unsafe fn from_raw_unchecked(raw: RawPid) -> Self
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const unsafe fn from_raw_unchecked(raw: RawPid) -> Self
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Converts a known positive RawPid into a Pid.
Passing a negative number doesn’t invoke undefined behavior, but it may cause unexpected behavior.
§Safety
The caller must guarantee raw is non-zero.
Sourcepub fn from_child(child: &Child) -> Self
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and crate feature std only.
pub fn from_child(child: &Child) -> Self
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and crate feature std only.Creates a Pid holding the ID of the given child process.
Sourcepub const fn as_raw_nonzero(self) -> NonZeroI32
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const fn as_raw_nonzero(self) -> NonZeroI32
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Converts a Pid into a NonZeroI32.
Sourcepub const fn as_raw_pid(self) -> RawPid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const fn as_raw_pid(self) -> RawPid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Converts a Pid into a RawPid.
This is the same as self.as_raw_nonzero().get().
Sourcepub const fn as_raw(pid: Option<Self>) -> RawPid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const fn as_raw(pid: Option<Self>) -> RawPid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Converts an Option<Pid> into a RawPid.
Sourcepub const fn is_init(self) -> bool
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
pub const fn is_init(self) -> bool
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Test whether this pid represents the init process (Pid::INIT).
Trait Implementations§
Source§impl Binary for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Binary for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl Clone for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Clone for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl Debug for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Debug for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl Display for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Display for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl Hash for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Hash for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl LowerExp for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and lower_upper_exp_for_non_zero only.
impl LowerExp for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and lower_upper_exp_for_non_zero only.Source§impl LowerHex for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl LowerHex for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl Octal for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl Octal for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl PartialEq for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl PartialEq for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.Source§impl UpperExp for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and lower_upper_exp_for_non_zero only.
impl UpperExp for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) and lower_upper_exp_for_non_zero only.Source§impl UpperHex for Pid
Available on neither Windows nor WASI and (crate feature process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.
impl UpperHex for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.impl Copy for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.impl Eq for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.impl StructuralPartialEq for Pid
process, or crate feature runtime, or crate feature termios, or crate feature thread, or bsd and crate feature event, or linux_kernel and crate feature net) only.