Struct std::run::Process

pub struct Process {
    priv pid: pid_t,
    priv handle: *(),
    priv input: Option<c_int>,
    priv output: Option<*FILE>,
    priv error: Option<*FILE>,
    priv exit_code: Option<int>,
}

A value representing a child process.

The lifetime of this value is linked to the lifetime of the actual process - the Process destructor calls self.finish() which waits for the process to terminate.

Methods

impl Process

fn new(prog: &str, args: &[~str], options: ProcessOptions) -> Process

Spawns a new Process.

Arguments

  • prog - The path to an executable.
  • args - Vector of arguments to pass to the child process.
  • options - Options to configure the environment of the process, the working directory and the standard IO streams.

fn get_id(&self) -> pid_t

Returns the unique id of the process

fn input_redirected(&self) -> bool

Returns whether this process is reading its stdin from an existing file descriptor rather than a pipe that was created specifically for this process.

If this method returns true then self.input() will fail.

fn output_redirected(&self) -> bool

Returns whether this process is writing its stdout to an existing file descriptor rather than a pipe that was created specifically for this process.

If this method returns true then self.output() will fail.

fn error_redirected(&self) -> bool

Returns whether this process is writing its stderr to an existing file descriptor rather than a pipe that was created specifically for this process.

If this method returns true then self.error() will fail.

fn input(&mut self) -> @Writer

Returns an io::Writer that can be used to write to this Process's stdin.

Fails if this Process's stdin was redirected to an existing file descriptor.

fn output(&mut self) -> @Reader

Returns an io::Reader that can be used to read from this Process's stdout.

Fails if this Process's stdout was redirected to an existing file descriptor.

fn error(&mut self) -> @Reader

Returns an io::Reader that can be used to read from this Process's stderr.

Fails if this Process's stderr was redirected to an existing file descriptor.

fn close_input(&mut self)

Closes the handle to the child process's stdin.

If this process is reading its stdin from an existing file descriptor, then this method does nothing.

fn finish(&mut self) -> int

Closes the handle to stdin, waits for the child process to terminate, and returns the exit code.

If the child has already been finished then the exit code is returned.

fn finish_with_output(&mut self) -> ProcessOutput

Closes the handle to stdin, waits for the child process to terminate, and reads and returns all remaining output of stdout and stderr, along with the exit code.

If the child has already been finished then the exit code and any remaining unread output of stdout and stderr will be returned.

This method will fail if the child process's stdout or stderr streams were redirected to existing file descriptors.

fn destroy(&mut self)

Terminates the process, giving it a chance to clean itself up if this is supported by the operating system.

On Posix OSs SIGTERM will be sent to the process. On Win32 TerminateProcess(..) will be called.

fn force_destroy(&mut self)

Terminates the process as soon as possible without giving it a chance to clean itself up.

On Posix OSs SIGKILL will be sent to the process. On Win32 TerminateProcess(..) will be called.

Trait Implementations

impl Drop for Process

fn drop(&mut self)