pub struct Process { /* private fields */ }Expand description
Process in a virtual system
Implementations§
Source§impl Process
impl Process
Sourcepub fn with_parent_and_group(ppid: Pid, pgid: Pid) -> Process
pub fn with_parent_and_group(ppid: Pid, pgid: Pid) -> Process
Creates a new running process.
Sourcepub fn fork_from(ppid: Pid, parent: &Process) -> Process
pub fn fork_from(ppid: Pid, parent: &Process) -> Process
Creates a new running process as a child of the given parent.
Some part of the parent process state is copied to the new process.
Sourcepub fn get_fd_mut(&mut self, fd: Fd) -> Option<&mut FdBody>
pub fn get_fd_mut(&mut self, fd: Fd) -> Option<&mut FdBody>
Returns the body for the given FD.
Sourcepub fn set_fd(&mut self, fd: Fd, body: FdBody) -> Result<Option<FdBody>, FdBody>
pub fn set_fd(&mut self, fd: Fd, body: FdBody) -> Result<Option<FdBody>, FdBody>
Assigns the given FD to the body.
If successful, returns an Ok value containing the previous body for
the FD. If the FD is equal to or greater than the current soft limit for
Resource::NOFILE, returns Err(body).
Sourcepub fn open_fd_ge(&mut self, min_fd: Fd, body: FdBody) -> Result<Fd, FdBody>
pub fn open_fd_ge(&mut self, min_fd: Fd, body: FdBody) -> Result<Fd, FdBody>
Assigns a new FD to the given body.
The new FD will be the minimum unused FD equal to or greater than
min_fd.
If successful, the new FD is returned in Ok.
If no more FD can be opened, returns Err(body).
Sourcepub fn open_fd(&mut self, body: FdBody) -> Result<Fd, FdBody>
pub fn open_fd(&mut self, body: FdBody) -> Result<Fd, FdBody>
Assigns a new FD to the given body.
The new FD will be the minimum unused FD, which will be returned as an
Ok value.
If no more FD can be opened, returns Err(body).
Sourcepub fn chdir(&mut self, path: PathBuf)
pub fn chdir(&mut self, path: PathBuf)
Changes the working directory.
This function does not check if the directory exists and is accessible.
Sourcepub fn wake_on_resumption(&mut self, waker: Weak<Cell<Option<Waker>>>)
pub fn wake_on_resumption(&mut self, waker: Weak<Cell<Option<Waker>>>)
Registers a waker that will be woken up when this process resumes.
The given waker will be woken up when this process is resumed by
set_state or raise_signal.
A strong reference to the waker must be held by the caller until the
waker is woken up, when the waker is consumed and the Cell content is
set to None.
This function does nothing if the process is not stopped.
Sourcepub fn state(&self) -> ProcessState
pub fn state(&self) -> ProcessState
Returns the process state.
Sourcepub fn set_state(&mut self, state: ProcessState) -> bool
pub fn set_state(&mut self, state: ProcessState) -> bool
Sets the state of this process.
If the new state is Exited or Signaled, all file descriptors in this
process are closed.
This function returns whether the state did change. If true, the
state_has_changed flag is set and the
caller must notify the state change by sending SIGCHLD to the parent
process.
Sourcepub fn state_has_changed(&self) -> bool
pub fn state_has_changed(&self) -> bool
Sourcepub fn take_state(&mut self) -> ProcessState
pub fn take_state(&mut self) -> ProcessState
Returns the process state and clears the
state_has_changed flag.
Sourcepub fn blocked_signals(&self) -> &BTreeSet<Number>
pub fn blocked_signals(&self) -> &BTreeSet<Number>
Returns the currently blocked signals.
Sourcepub fn pending_signals(&self) -> &BTreeSet<Number>
pub fn pending_signals(&self) -> &BTreeSet<Number>
Returns the currently pending signals.
A signal is pending when it has been raised but not yet delivered because it is being blocked.
Sourcepub fn block_signals(
&mut self,
how: SigmaskOp,
signals: &[Number],
) -> SignalResult
pub fn block_signals( &mut self, how: SigmaskOp, signals: &[Number], ) -> SignalResult
Updates the signal blocking mask for this process.
If this function unblocks a signal, any pending signal is delivered.
If the signal changes the execution state of the process, this function
returns a SignalResult with process_state_changed being true. In
that case, the caller must send a SIGCHLD to the parent process of this
process.
Sourcepub fn disposition(&self, number: Number) -> Disposition
pub fn disposition(&self, number: Number) -> Disposition
Returns the current disposition for a signal.
If no disposition is set for the signal, the default disposition is returned.
Sourcepub fn set_disposition(
&mut self,
number: Number,
disposition: Disposition,
) -> Disposition
pub fn set_disposition( &mut self, number: Number, disposition: Disposition, ) -> Disposition
Gets and sets the disposition for a signal.
This function sets the disposition to the given value and returns the previous disposition.
Sourcepub fn raise_signal(&mut self, signal: Number) -> SignalResult
pub fn raise_signal(&mut self, signal: Number) -> SignalResult
Sends a signal to this process.
If the signal is being blocked, it will remain pending. Otherwise, it is immediately delivered.
If the signal changes the execution state of the process, this function
returns a SignalResult with process_state_changed being true. In
that case, the caller must send a SIGCHLD to the parent process of this
process.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Process
impl !RefUnwindSafe for Process
impl !Send for Process
impl !Sync for Process
impl Unpin for Process
impl !UnwindSafe for Process
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more