class Process::Child
A child process that Process.spawn started, which runs alongside the
program until it ends.
Several tasks may hold it: one waits for it while another signals it.
A child dropped without #wait is not killed: it goes on running,
and once it has ended it stays a zombie (a process-table entry) until
the program exits, unless it had ended already when the value was
released, which reaps it.
Methods
def pid -> Int
The child's process id.
def wait -> Process::Status
Waits for the child to end and returns how it ended; only the
calling task waits. A second wait, or one after the child ended,
returns the same status.
Task.timeout and Task#cancel interrupt the wait (the task gets
Task::Timeout or Task::Cancelled): the child goes on, and can
still be waited for or signalled.
def status -> Process::Status?
How the child ended, or nil while it runs (without waiting).
def running? -> Bool
Whether the child is still running.
def signal(name: Symbol | String) -> Void
Sends the signal name (:TERM, "TERM", "SIGTERM"; one of
Signal.names) to the child. Sending to a child that has ended does
nothing.
Raises
ArgumentError for a signal not in Signal.names.
def kill -> Void
Ends the child at once (signal(:KILL)).
def stdin -> IO
The pipe to the child's standard input, when it was spawned with
stdin: :pipe: write to it, and close it to end the child's input.
Raises
ArgumentError when stdin was not :pipe.
def stdout -> IO
The pipe from the child's standard output, when it was spawned with
stdout: :pipe.
A child writing to two pipes waits once one of them is full: read both (from two tasks), or the child may never end.
Raises
ArgumentError when stdout was not :pipe.
def stderr -> IO
The pipe from the child's standard error, when it was spawned with
stderr: :pipe (see #stdout).
Raises
ArgumentError when stderr was not :pipe.