[src]

Struct std::io::process::ProcessConfig

pub struct ProcessConfig<'a> {
    program: &'a str,
    args: &'a [~str],
    env: Option<&'a [(~str, ~str)]>,
    cwd: Option<&'a Path>,
    stdin: StdioContainer,
    stdout: StdioContainer,
    stderr: StdioContainer,
    extra_io: &'a [StdioContainer],
    uid: Option<uint>,
    gid: Option<uint>,
    detach: bool,
}

This configuration describes how a new process should be spawned. A blank configuration can be created with ProcessConfig::new(). It is also recommented to use a functional struct update pattern when creating process configuration:

use std::io::ProcessConfig;

let config = ProcessConfig {
    program: "/bin/sh",
    args: &[~"-c", ~"true"],
    .. ProcessConfig::new()
};

Fields

program

Path to the program to run

args

Arguments to pass to the program (doesn't include the program itself)

env

Optional environment to specify for the program. If this is None, then it will inherit the current process's environment.

cwd

Optional working directory for the new process. If this is None, then the current directory of the running process is inherited.

stdin

Configuration for the child process's stdin handle (file descriptor 0). This field defaults to CreatePipe(true, false) so the input can be written to.

stdout

Configuration for the child process's stdout handle (file descriptor 1). This field defaults to CreatePipe(false, true) so the output can be collected.

stderr

Configuration for the child process's stdout handle (file descriptor 2). This field defaults to CreatePipe(false, true) so the output can be collected.

extra_io

Any number of streams/file descriptors/pipes may be attached to this process. This list enumerates the file descriptors and such for the process to be spawned, and the file descriptors inherited will start at 3 and go to the length of this array. The first three file descriptors (stdin/stdout/stderr) are configured with the stdin, stdout, and stderr fields.

uid

Sets the child process's user id. This translates to a setuid call in the child process. Setting this value on windows will cause the spawn to fail. Failure in the setuid call on unix will also cause the spawn to fail.

gid

Similar to uid, but sets the group id of the child process. This has the same semantics as the uid field.

detach

If true, the child process is spawned in a detached state. On unix, this means that the child is the leader of a new process group.

Methods

impl<'a> ProcessConfig<'a>

fn new<'a>() -> ProcessConfig<'a>

Creates a new configuration with blanks as all of the defaults. This is useful when using functional struct updates:

use std::io::process::{ProcessConfig, Process};

let config = ProcessConfig {
    program: "/bin/sh",
    args: &[~"-c", ~"echo hello"],
    .. ProcessConfig::new()
};

let p = Process::configure(config);