Process

Struct Process 

Source
pub struct Process { /* private fields */ }
Expand description

Process in a virtual system

Implementations§

Source§

impl Process

Source

pub fn with_parent_and_group(ppid: Pid, pgid: Pid) -> Process

Creates a new running process.

Source

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.

Source

pub fn ppid(&self) -> Pid

Returns the process ID of the parent process.

Source

pub fn pgid(&self) -> Pid

Returns the process group ID of this process.

Source

pub fn uid(&self) -> Uid

Returns the real user ID of this process.

Source

pub fn set_uid(&mut self, uid: Uid)

Sets the real user ID of this process.

Source

pub fn euid(&self) -> Uid

Returns the effective user ID of this process.

Source

pub fn set_euid(&mut self, euid: Uid)

Sets the effective user ID of this process.

Source

pub fn gid(&self) -> Gid

Returns the real group ID of this process.

Source

pub fn set_gid(&mut self, gid: Gid)

Sets the real group ID of this process.

Source

pub fn egid(&self) -> Gid

Returns the effective group ID of this process.

Source

pub fn set_egid(&mut self, egid: Gid)

Sets the effective group ID of this process.

Source

pub fn fds(&self) -> &BTreeMap<Fd, FdBody>

Returns FDs open in this process.

Source

pub fn get_fd(&self, fd: Fd) -> Option<&FdBody>

Returns the body for the given FD.

Source

pub fn get_fd_mut(&mut self, fd: Fd) -> Option<&mut FdBody>

Returns the body for the given FD.

Source

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).

Source

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).

Source

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).

Source

pub fn close_fd(&mut self, fd: Fd) -> Option<FdBody>

Removes the FD body for the given FD.

Source

pub fn close_fds(&mut self)

Removes all FD bodies in this process.

Source

pub fn getcwd(&self) -> &Path

Returns the working directory path.

Source

pub fn chdir(&mut self, path: PathBuf)

Changes the working directory.

This function does not check if the directory exists and is accessible.

Source

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.

Source

pub fn state(&self) -> ProcessState

Returns the process state.

Source

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.

Source

pub fn state_has_changed(&self) -> bool

Returns true if a new state has been set but not yet taken.

Source

pub fn take_state(&mut self) -> ProcessState

Returns the process state and clears the state_has_changed flag.

Source

pub fn blocked_signals(&self) -> &BTreeSet<Number>

Returns the currently blocked signals.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn last_exec(&self) -> &Option<(CString, Vec<CString>, Vec<CString>)>

Returns the arguments to the last call to execve on this process.

Trait Implementations§

Source§

impl Clone for Process

Source§

fn clone(&self) -> Process

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Process

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.