pub struct OwnedCommand { /* private fields */ }Implementations§
Source§impl OwnedCommand
impl OwnedCommand
pub fn new(program: impl AsRef<OsStr>) -> Self
Sourcepub fn from_command(command: Command) -> Self
pub fn from_command(command: Command) -> Self
GUI/service children are hidden on Windows by default. A wrapped Command may carry
stdio, environment and raw-argument settings this crate cannot read back, so on
Windows an allowlisted spawn (inherit_handles_only) from from_command requires an
explicit windows_spawn_config. The crate never widens what a child inherits by
default.
pub fn command_mut(&mut self) -> &mut Command
Sourcepub fn inherit_handles_only(
&mut self,
handles: impl IntoIterator<Item = RawHandleOrFd>,
) -> &mut Self
pub fn inherit_handles_only( &mut self, handles: impl IntoIterator<Item = RawHandleOrFd>, ) -> &mut Self
Inherit only these handles/fds plus configured stdio; values stay caller-owned.
Sourcepub fn env_allowlist<I, S>(&mut self, keys: I) -> &mut Self
pub fn env_allowlist<I, S>(&mut self, keys: I) -> &mut Self
Clear environment, then copy only named variables set in this process.
Sourcepub fn env_allowlist_with_defaults<I, S>(&mut self, extra: I) -> &mut Self
pub fn env_allowlist_with_defaults<I, S>(&mut self, extra: I) -> &mut Self
Self::env_allowlist over DEFAULT_ENV_ALLOWLIST plus extra (a consumer’s own
variables, for instance a model-cache location). Call it once: like env_allowlist it
starts from an empty environment, so a second call drops what the first kept.
Sourcepub fn env_is_cleared(&self) -> bool
pub fn env_is_cleared(&self) -> bool
True once Self::env_allowlist (or env_allowlist_with_defaults) cleared the inherited
environment on this command. A Command that was cleared with env_clear directly, or
wrapped by from_command after it was cleared, reads false: the state is not observable
from std::process::Command.
pub fn env_strip<I, S>(&mut self, keys: I) -> &mut Self
Sourcepub fn windows_hide(&mut self) -> &mut Self
pub fn windows_hide(&mut self) -> &mut Self
Compatibility no-op: hidden is already the default.
Sourcepub fn job_assignment_mode(&mut self, mode: JobAssignmentMode) -> &mut Self
pub fn job_assignment_mode(&mut self, mode: JobAssignmentMode) -> &mut Self
Ignored on Unix. BestEffort reports errors on OwnedChild.
Sourcepub fn unix_containment(&mut self, mode: UnixContainment) -> &mut Self
pub fn unix_containment(&mut self, mode: UnixContainment) -> &mut Self
Ignored on Windows. Session runs setsid before exec.
Sourcepub fn kill_on_parent_exit(&mut self, enabled: bool) -> &mut Self
pub fn kill_on_parent_exit(&mut self, enabled: bool) -> &mut Self
Opt-in, off by default. Linux only: the kernel sends SIGTERM to the direct child
(PR_SET_PDEATHSIG) when the thread that spawned it exits, which includes this
process dying without running cleanup (for example SIGKILL). The signal reaches the
direct child only, never the rest of its group, it can be caught, and there is no
SIGKILL escalation. It is keyed to the spawning thread, so spawn from a thread
that lives as long as the child.
Other Unix hosts, macOS included, have no parent-death primitive this crate relies on:
the spawn fails with ErrorKind::Unsupported before anything is started, rather than
run the child untied. Windows ignores the option because kill-on-close job objects
already cover parent death. Rejected (InvalidInput) for detached spawns.
Sourcepub fn partial_spawn_cleanup_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn partial_spawn_cleanup_timeout(&mut self, timeout: Duration) -> &mut Self
Bound failed-spawn cleanup. Timed-out children go to a background reaper.
pub fn spawn(self) -> Result<OwnedChild>
Sourcepub fn spawn_uncontained_detached(self) -> Result<OwnedChild>
pub fn spawn_uncontained_detached(self) -> Result<OwnedChild>
Shared launch with no owner job or terminate-on-drop. Unix uses setsid; Windows requires breakaway and never falls back when escape is denied. Stdio follows Command: dropping piped stdin can still deliver EOF.