Skip to main content

ChildProcessStarter

Type Alias ChildProcessStarter 

Source
pub type ChildProcessStarter<S> = Box<dyn FnOnce(&mut Env<S>, ChildProcessTask<S>) -> Pid>;
Expand description

Abstract function that starts a child process

Fork::new_child_process returns a child process starter. You need to pass the parent environment and a task to the starter to complete the child process creation. The starter provides a unified interface that hides the differences between RealSystem and VirtualSystem.

RealSystem::new_child_process performs a fork system call and returns a starter in the parent and child processes. When the starter is called in the parent, it just returns the child process ID. The starter in the child process runs the task and exits the process with the exit status of the task.

VirtualSystem::new_child_process does not create a real child process. Instead, the starter runs the task concurrently in the current process using the executor contained in the system. A new Process is added to the system to represent the child process. The starter returns its process ID.

This function only starts the child, which continues to run asynchronously after the function returns its PID. To wait for the child to finish and obtain its exit status, use wait.

Aliased Typeยง

pub struct ChildProcessStarter<S>(/* private fields */);