pub struct Process { /* private fields */ }Expand description
A handle to a spawned process.
§Fork Safety
The process handle contains a PID. After a fork, the child process will
have a copy of this PID, but it refers to the same original process.
Calling wait or kill from the child may lead to confusing results
if multiple processes are managing the same PID.
Implementations§
Source§impl Process
impl Process
Sourcepub fn wait_step(&self) -> Result<Option<ExitStatus>, CoreError>
pub fn wait_step(&self) -> Result<Option<ExitStatus>, CoreError>
Perform a non-blocking wait for process termination.
§Errors
ECHILD: The process does not exist or is not a child of the caller.EINTR: The call was interrupted by a signal (handled internally).
Sourcepub fn wait_blocking(&self) -> Result<ExitStatus, CoreError>
pub fn wait_blocking(&self) -> Result<ExitStatus, CoreError>
Block until the process terminates.
§Errors
ECHILD: The process does not exist or is not a child of the caller.
Sourcepub fn kill(&self, sig: i32) -> Result<(), CoreError>
pub fn kill(&self, sig: i32) -> Result<(), CoreError>
Send a signal to the process.
§Errors
EINVAL: Invalid signal number.EPERM: The caller does not have permission to send the signal.ESRCH: The process does not exist.
Sourcepub fn kill_pgroup(&self, sig: i32) -> Result<(), CoreError>
pub fn kill_pgroup(&self, sig: i32) -> Result<(), CoreError>
Signal the process group whose id equals Self::pid — valid only
when the process is its own group/session leader. For a child placed
into a custom leader’s group use Self::kill_group.
§Errors
Same as Self::kill.
Sourcepub fn kill_group(&self, pgid: pid_t, sig: i32) -> Result<(), CoreError>
pub fn kill_group(&self, pgid: pid_t, sig: i32) -> Result<(), CoreError>
Send a signal to an explicit process group.
The pgid must be the child’s actual group (its own pid after setsid,
or the configured leader’s id after setpgid), never guessed from the
pid.
§Errors
Same as Self::kill.