pub struct Process { /* private fields */ }Expand description
A process.
Implementations§
Source§impl Process
impl Process
Sourcepub fn is_init(self: &Arc<Self>) -> bool
pub fn is_init(self: &Arc<Self>) -> bool
Returns true if the Process is the init process.
This is a convenience method for checking if the Process
Arc::ptr_eqs with the init process, which is cheaper than
calling init_proc or testing if Process::parent is None.
Sourcepub fn is_child_subreaper(&self) -> bool
pub fn is_child_subreaper(&self) -> bool
Returns true if this process acts as a child subreaper.
Linux keeps this flag per process: it is preserved across execve,
applies to all threads in the thread group, and is not inherited by
newly forked child processes.
Sourcepub fn set_child_subreaper(&self, enabled: bool)
pub fn set_child_subreaper(&self, enabled: bool)
Enables or disables child subreaper behavior for this process.
Source§impl Process
impl Process
Sourcepub fn group(&self) -> Arc<ProcessGroup>
pub fn group(&self) -> Arc<ProcessGroup>
The ProcessGroup that the Process belongs to.
Sourcepub fn create_session(
self: &Arc<Self>,
) -> Option<(Arc<Session>, Arc<ProcessGroup>)>
pub fn create_session( self: &Arc<Self>, ) -> Option<(Arc<Session>, Arc<ProcessGroup>)>
Creates a new Session and new ProcessGroup and moves the
Process to it.
If the Process is already a session leader, this method does
nothing and returns None.
Otherwise, it returns the new Session and ProcessGroup.
The caller has to ensure that the new ProcessGroup does not conflict
with any existing ProcessGroup. Thus, the Process must not
be a ProcessGroup leader.
Checking Session conflicts is unnecessary.
Sourcepub fn create_group(self: &Arc<Self>) -> Option<Arc<ProcessGroup>>
pub fn create_group(self: &Arc<Self>) -> Option<Arc<ProcessGroup>>
Creates a new ProcessGroup and moves the Process to it.
If the Process is already a group leader, this method does nothing
and returns None.
Otherwise, it returns the new ProcessGroup.
The caller has to ensure that the new ProcessGroup does not conflict
with any existing ProcessGroup.
Sourcepub fn move_to_group(self: &Arc<Self>, group: &Arc<ProcessGroup>) -> bool
pub fn move_to_group(self: &Arc<Self>, group: &Arc<ProcessGroup>) -> bool
Moves the Process to a specified ProcessGroup.
Returns true if the move succeeded. The move failed if the
ProcessGroup is not in the same Session as the Process.
If the Process is already in the specified ProcessGroup, this
method does nothing and returns true.
Source§impl Process
Threads
impl Process
Threads
Sourcepub fn add_thread(self: &Arc<Self>, tid: Pid)
pub fn add_thread(self: &Arc<Self>, tid: Pid)
Adds a thread to this Process with the given thread ID.
Sourcepub fn exit_thread(self: &Arc<Self>, tid: Pid, exit_code: i32) -> bool
pub fn exit_thread(self: &Arc<Self>, tid: Pid, exit_code: i32) -> bool
Removes a thread from this Process and sets the exit code if the
group has not exited.
Returns true if this was the last thread in the process.
Sourcepub fn rename_thread(self: &Arc<Self>, old_tid: Pid, new_tid: Pid)
pub fn rename_thread(self: &Arc<Self>, old_tid: Pid, new_tid: Pid)
Renames a thread in the thread group.
Used by execve’s de_thread step when a non-leader thread successfully
execves: the calling thread inherits the leader’s TID so that
gettid() == getpid() holds in the new image. We swap old_tid for
new_tid atomically inside the thread-group lock so there is no
instant in which the caller is unrepresented in the group.
Sourcepub fn is_group_exited(&self) -> bool
pub fn is_group_exited(&self) -> bool
Returns true if the Process is group exited.
Sourcepub fn group_exit(&self)
pub fn group_exit(&self)
Marks the Process as group exited.