Skip to main content

OwnedCommand

Struct OwnedCommand 

Source
pub struct OwnedCommand { /* private fields */ }

Implementations§

Source§

impl OwnedCommand

Source

pub fn new(program: impl AsRef<OsStr>) -> Self

Source

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.

Source

pub fn command_mut(&mut self) -> &mut Command

Source

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.

Source

pub fn env_allowlist<I, S>(&mut self, keys: I) -> &mut Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Clear environment, then copy only named variables set in this process.

Source

pub fn env_allowlist_with_defaults<I, S>(&mut self, extra: I) -> &mut Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

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.

Source

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.

Source

pub fn env_strip<I, S>(&mut self, keys: I) -> &mut Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Source

pub fn windows_hide(&mut self) -> &mut Self

Compatibility no-op: hidden is already the default.

Source

pub fn job_assignment_mode(&mut self, mode: JobAssignmentMode) -> &mut Self

Ignored on Unix. BestEffort reports errors on OwnedChild.

Source

pub fn unix_containment(&mut self, mode: UnixContainment) -> &mut Self

Ignored on Windows. Session runs setsid before exec.

Source

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.

Source

pub fn partial_spawn_cleanup_timeout(&mut self, timeout: Duration) -> &mut Self

Bound failed-spawn cleanup. Timed-out children go to a background reaper.

Source

pub fn spawn(self) -> Result<OwnedChild>

Source

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.

Trait Implementations§

Source§

impl Debug for OwnedCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.