module Process

The running program and the child processes it runs.

out = Process.run("echo", "hello")
out.stdout                         # => "hello\n"
out.success?                       # => true
Process.sh("echo oops >&2; exit 3")
# => Process::Output(status: 3, stdout: "", stderr: "oops\n")

<prelude>:6586

Classes and modules

Class methods

def self.argv -> Array[String]

The program's arguments, without the program's name (as ARGV).

<prelude>:6602

def self.env -> Hash[String, String]

The environment variables, as they are when it is called (as ENV, which is read at start-up).

<prelude>:6605

def self.pid -> Int

The process's id.

<prelude>:6607

def self.stdin -> IO

The standard input (STDIN).

<prelude>:6609

def self.stdout -> IO

The standard output (STDOUT).

<prelude>:6611

def self.stderr -> IO

The standard error (STDERR).

<prelude>:6613

def self.clock -> Float

The seconds since the program started, from a clock that never goes back (Time.monotonic as a Float).

<prelude>:6616

def self.run(*command: String) -> Process::Output

Runs the program command[0] with the arguments that follow, with no shell between, and waits for it to end; only the calling task waits.

The child's standard input is empty, and its standard output and error are collected into the result. A failing status is not an error: check Output#success?.

Raises

SystemCallError when the program cannot be started (not found, not executable); ArgumentError when command is empty.

<prelude>:6628

def self.sh(script: String) -> Process::Output

Runs script with sh -c, as .run runs a program.

<prelude>:6630