pub struct SpawnSpec { /* private fields */ }Expand description
Typed spawn description accepted by the blessed process boundary.
Implementations§
Source§impl SpawnSpec
impl SpawnSpec
Sourcepub fn new(program: impl Into<OsString>) -> Self
pub fn new(program: impl Into<OsString>) -> Self
Create a direct (non-shell) command description.
Sourcepub fn arg(self, arg: impl Into<OsString>) -> Self
pub fn arg(self, arg: impl Into<OsString>) -> Self
Append one argument without requiring UTF-8.
Sourcepub fn current_dir(self, path: impl Into<PathBuf>) -> Self
pub fn current_dir(self, path: impl Into<PathBuf>) -> Self
Set the child working directory.
Sourcepub fn env(self, key: impl Into<OsString>, value: impl Into<OsString>) -> Self
pub fn env(self, key: impl Into<OsString>, value: impl Into<OsString>) -> Self
Add an environment override.
Sourcepub fn clear_env(self, clear: bool) -> Self
pub fn clear_env(self, clear: bool) -> Self
Start with an empty inherited environment before applying overrides.
Sourcepub fn stdin(self, mode: StreamMode) -> Self
pub fn stdin(self, mode: StreamMode) -> Self
Configure child stdin.
Sourcepub fn stdout(self, mode: StreamMode) -> Self
pub fn stdout(self, mode: StreamMode) -> Self
Configure child stdout.
Sourcepub fn stderr(self, mode: StreamMode) -> Self
pub fn stderr(self, mode: StreamMode) -> Self
Configure child stderr.
Sourcepub fn create_process_group(self, create: bool) -> Self
pub fn create_process_group(self, create: bool) -> Self
Put the child in its own process group.
This is what makes a group-wide soft signal addressable at all:
PlatformEmergencySignal::terminate_group_soft is a no-op without
it, because on POSIX the negative-PID signal would otherwise reach the
caller’s own group, and on Windows GenerateConsoleCtrlEvent only
routes to children spawned with CREATE_NEW_PROCESS_GROUP. It also
detaches the child from the parent’s console Ctrl+C, so it is opt-in.
Sourcepub fn kill_when_owner_dies(self, kill: bool) -> Self
pub fn kill_when_owner_dies(self, kill: bool) -> Self
Kill this child when the spawning process exits unexpectedly.
Linux uses PR_SET_PDEATHSIG(SIGTERM). Windows assigns the child to a
process-wide kill-on-close Job Object. macOS retains the modeled
kqueue-supervisor contract; its concrete supervisor is not part of the
async platform spawn seam yet.
Sourcepub async fn spawn(self) -> Result<PlatformChild>
pub async fn spawn(self) -> Result<PlatformChild>
Spawn using the canonical asynchronous platform operation.