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 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