Struct unshare::Command
[−]
[src]
pub struct Command { // some fields omitted }
Methods
impl Command
[src]
fn new<S: AsRef<OsStr>>(program: S) -> Command
Constructs a new Command
for launching the program at
path program
, with the following default configuration:
- No arguments to the program
- Inherit the current process's environment
- Inherit the current process's working directory
- Inherit stdin/stdout/stderr for
spawn
orstatus
, but create pipes foroutput
Builder methods are provided to change these defaults and otherwise configure the process.
fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Command
Add an argument to pass to the program.
fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Command
Add multiple arguments to pass to the program.
fn init_env_map(&mut self)
fn env<K, V>(&mut self, key: K, val: V) -> &mut Command where K: AsRef<OsStr>, V: AsRef<OsStr>
Inserts or updates an environment variable mapping.
fn env_remove<K: AsRef<OsStr>>(&mut self, key: K) -> &mut Command
Removes an environment variable mapping.
fn env_clear(&mut self) -> &mut Command
Clears the entire environment map for the child process.
fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Command
Sets the working directory for the child process.
Note: in case of chroot or pivot root the working directory is set inside the new root.
However, if you leave current_dir
unspecified chroot will translate
directory path, if possible or otherwise set root dir to new root.
The pivot_root behaves same as chroot, i.e. it doesn't set current
directory in old_root
.
At the end of the day, the cmd.current_dir(env::current_dir())
is
not no-op if using chroot/pivot_root.
fn stdin(&mut self, cfg: Stdio) -> &mut Command
Configuration for the child process's stdin handle (file descriptor 0).
fn stdout(&mut self, cfg: Stdio) -> &mut Command
Configuration for the child process's stdout handle (file descriptor 1).
fn stderr(&mut self, cfg: Stdio) -> &mut Command
Configuration for the child process's stderr handle (file descriptor 2).