Struct Command

Source
pub struct Command {
Show 16 fields program: CString, args: Vec<CString>, argv: Argv, env: CommandEnv, program_kind: ProgramKind, cwd: Option<CString>, uid: Option<uid_t>, gid: Option<gid_t>, saw_nul: bool, closures: Vec<Box<dyn FnMut() -> Result<()> + Send + Sync>>, groups: Option<Box<[gid_t]>>, stdin: Option<Stdio>, stdout: Option<Stdio>, stderr: Option<Stdio>, create_pidfd: bool, pgroup: Option<pid_t>,
}

Fields§

§program: CString§args: Vec<CString>§argv: Argv

Exactly what will be passed to execvp.

First element is a pointer to program, followed by pointers to args, followed by a null. Be careful when modifying program or args to properly update this as well.

§env: CommandEnv§program_kind: ProgramKind§cwd: Option<CString>§uid: Option<uid_t>§gid: Option<gid_t>§saw_nul: bool§closures: Vec<Box<dyn FnMut() -> Result<()> + Send + Sync>>§groups: Option<Box<[gid_t]>>§stdin: Option<Stdio>§stdout: Option<Stdio>§stderr: Option<Stdio>§create_pidfd: bool§pgroup: Option<pid_t>

Implementations§

Source§

impl Command

Source

pub fn new(program: &OsStr) -> Command

Source

pub fn set_arg_0(&mut self, arg: &OsStr)

Source

pub fn arg(&mut self, arg: &OsStr)

Source

pub fn cwd(&mut self, dir: &OsStr)

Source

pub fn uid(&mut self, id: uid_t)

Source

pub fn gid(&mut self, id: gid_t)

Source

pub fn groups(&mut self, groups: &[gid_t])

Source

pub fn pgroup(&mut self, pgroup: pid_t)

Source

pub fn create_pidfd(&mut self, val: bool)

Source

pub fn get_create_pidfd(&self) -> bool

Source

pub fn saw_nul(&self) -> bool

Source

pub fn get_program(&self) -> &OsStr

Source

pub fn get_program_kind(&self) -> ProgramKind

Source

pub fn get_args(&self) -> CommandArgs<'_>

Source

pub fn get_envs(&self) -> CommandEnvs<'_>

Source

pub fn get_current_dir(&self) -> Option<&Path>

Source

pub fn get_argv(&self) -> &Vec<*const c_char>

Source

pub fn get_program_cstr(&self) -> &CStr

Source

pub fn get_cwd(&self) -> Option<&CStr>

Source

pub fn get_uid(&self) -> Option<uid_t>

Source

pub fn get_gid(&self) -> Option<gid_t>

Source

pub fn get_groups(&self) -> Option<&[gid_t]>

Source

pub fn get_pgroup(&self) -> Option<pid_t>

Source

pub fn get_closures( &mut self, ) -> &mut Vec<Box<dyn FnMut() -> Result<()> + Send + Sync>>

Source

pub unsafe fn pre_exec( &mut self, f: Box<dyn FnMut() -> Result<()> + Send + Sync>, )

Source

pub fn stdin(&mut self, stdin: Stdio)

Source

pub fn stdout(&mut self, stdout: Stdio)

Source

pub fn stderr(&mut self, stderr: Stdio)

Source

pub fn env_mut(&mut self) -> &mut CommandEnv

Source

pub fn capture_env(&mut self) -> Option<CStringArray>

Source

pub fn env_saw_path(&self) -> bool

Source

pub fn program_is_path(&self) -> bool

Source

pub fn setup_io( &self, default: Stdio, needs_stdin: bool, ) -> Result<(StdioPipes, ChildPipes)>

Source§

impl Command

Source

pub fn spawn( &mut self, default: Stdio, needs_stdin: bool, ) -> Result<(Process, StdioPipes)>

Source

unsafe fn do_fork(&mut self) -> Result<pid_t, Error>

Source

pub fn exec(&mut self, default: Stdio) -> Error

Source

unsafe fn do_exec( &mut self, stdio: ChildPipes, maybe_envp: Option<&CStringArray>, ) -> Result<!, Error>

Source

fn posix_spawn( &mut self, stdio: &ChildPipes, envp: Option<&CStringArray>, ) -> Result<Option<Process>>

Source

fn send_pidfd(&self, sock: &Socket)

Source

fn recv_pidfd(&self, sock: &Socket) -> pid_t

Trait Implementations§

Source§

impl AsInner<Command> for Command

Source§

impl AsInnerMut<Command> for Command

Source§

fn as_inner_mut(&mut self) -> &mut Command

Source§

impl Debug for Command

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> SizedTypeProperties for T

Source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)] const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)] const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.