pub enum SpawnBackend {
PosixSpawn,
Fork,
Vfork,
Clone3,
Clone3Pidfd,
}Expand description
Explicit process spawning backend.
Variants§
PosixSpawn
Force the use of posix_spawn.
Fork
Force the use of fork/exec.
The fork backend supports explicit SpawnFdPolicy handling before
execve.
Vfork
Force the use of vfork/exec.
vfork shares the parent’s address space with the child until it
execves (or _exits), so it avoids the page-table work of fork.
The child runs only async-signal-safe setup before execve, and the
calling thread is blocked until the child execs. Safe for the child
because the Linux vfork child inherits a copy of the descriptor
table, so SpawnFdPolicy handling works as with SpawnBackend::Fork.
Use only when the shared-address-space semantics are understood: the child must never return from the spawn entry point, and a bug in the child setup can corrupt the parent’s memory.
Clone3
Force the use of clone3(2)/exec (kernel 5.3+).
clone3 with process flags creates a child with copy-on-write memory
and a copied descriptor table, like SpawnBackend::Fork, but lets the
caller control clone flags directly. Supported by the same child setup
as the fork backend. Returns ENOSYS on kernels without clone3.
Clone3Pidfd
Force the use of clone3(2) with CLONE_PIDFD + exec (kernel 5.3+).
Identical to SpawnBackend::Clone3, but the kernel additionally hands
the parent a pidfd for the child. The resulting Process carries that
pidfd: signaling uses pidfd_send_signal (immune to pid reuse), and
exit detection polls the pidfd instead of polling waitpid. Returns
ENOSYS on kernels without clone3.
Trait Implementations§
Source§impl Clone for SpawnBackend
impl Clone for SpawnBackend
Source§fn clone(&self) -> SpawnBackend
fn clone(&self) -> SpawnBackend
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more