Lyricdev
GitHub

class Child

pub class Child

A started child process: its standard streams where the command piped them, waiting for its end, and signalling it.

Fields

pub var stdin: ?PipeWriter

The child's standard input, where the command piped it: close it to end the child's input.

pub stdout: ?PipeReader

The child's standard output, where the command piped it.

pub stderr: ?PipeReader

The child's standard error, where the command piped it.

Methods

pub mut fn wait(): ExitStatus throws [IoError, Cancelled]

Waits until the child has ended and returns how. A piped standard input is closed first: otherwise a child reading it would wait for the parent while the parent waits for the child.

Errors

Throws IoError when closing the input or waiting fails, and Cancelled when the waiting task is cancelled.

pub fn kill(): void throws IoError

Ends the child now — SIGKILL on POSIX, TerminateProcess on Windows (code 1). A child that has ended already is not touched: its process id may belong to another process by then.

Errors

Throws IoError when the system refuses the signal.

pub fn signal(s: Signal): void throws IoError

Sends the signal s to the child, where it has not ended.

Errors

Throws IoError: Unsupported for a signal the system does not have — on Windows every signal but a kill —, and the system's failure when it refuses the signal.