Process spawning

Interface Program

A value representing a child process

Method get_id

fn get_id() -> pid_t

Returns the process id of the program

Method input

fn input() -> io::Writer

Returns an io::writer that can be used to write to stdin

Method output

fn output() -> io::Reader

Returns an io::reader that can be used to read from stdout

Method err

fn err() -> io::Reader

Returns an io::reader that can be used to read from stderr

Method close_input

fn close_input()

Closes the handle to the child processes standard input

Method finish

fn finish() -> int

Waits for the child process to terminate. Closes the handle to stdin if necessary.

Method destroy

fn destroy()

Closes open handles

Function program_output

fn program_output(prog: &str, args: &[~str]) ->
 {status: int, out: ~str, err: ~str,}

Spawns a process, waits for it to exit, and returns the exit code, and contents of stdout and stderr.

Arguments

Return value

A record, {status: int, out: str, err: str} containing the exit code, the contents of stdout and the contents of stderr.

Function read_all

fn read_all(rd: io::Reader) -> ~str

Function readclose

fn readclose(fd: c_int) -> ~str

Function run_program

fn run_program(prog: &str, args: &[~str]) -> int

Spawns a process and waits for it to terminate

Arguments

Return value

The process id

Function spawn_process

fn spawn_process(prog: &str, args: &[~str], env: &Option<~[(~str, ~str)]>,
                 dir: &Option<~str>, in_fd: c_int, out_fd: c_int,
                 err_fd: c_int) -> pid_t

Run a program, providing stdin, stdout and stderr handles

Arguments

Return value

The process id of the spawned process

Function start_program

fn start_program(prog: &str, args: &[~str]) -> Program

Spawns a process and returns a program

The returned value is a boxed class containing a object that can be used for sending and receiving data over the standard file descriptors. The class will ensure that file descriptors are closed properly.

Arguments

Return value

A class with a field

Function waitpid

fn waitpid(pid: pid_t) -> int

Waits for a process to exit and returns the exit code

Function with_argv

fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T

Function with_dirp

fn with_dirp<T>(d: &Option<~str>, cb: &fn(*libc::c_char) -> T) -> T

Function with_envp

fn with_envp<T>(env: &Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T

Function writeclose

fn writeclose(fd: c_int, s: ~str)