std.process [core] std.process.Command pub struct Command { argv: List[str], fds: List[int], } — A program and its arguments, as the argument VECTOR the host receives. std.process.Child pub struct Child { slot: int, } — A started child process: this machine's handle on it. std.process.command pub fn command(program: str) -> Command — A Command that runs program with no arguments. std.process.from_argv pub fn from_argv(argv: List[str]) -> Command — A Command from a whole argument vector: element 0 is the program, the rest are its arguments. std.process.push_arg pub fn push_arg(mut c: Command, value: str) — Append one argument to c. std.process.argv pub fn argv(c: Command) -> List[str] — c's argument vector: the program first, then its arguments. std.process.Pipe pub struct Pipe { read: fs.File, write: fs.File, } — The two ends of a pipe: what is written to write is read from read, in order, and read answers eof once every copy of write is closed — this program's and every child's. std.process.pipe pub fn pipe() -> Pipe ! {io} — A new pipe. std.process.set_fd pub fn set_fd(mut c: Command, child: int, f: fs.File) — The child gets f as descriptor child — a shell's Nfile or N>&M, spelled as data: child is the number the CHILD sees, and f is a file this program holds (fs.open's, a pipe end, or fs.stdin()/fs.stdout()/fs.stderr() for this program's own streams). std.process.set_stdin pub fn set_stdin(mut c: Command, f: fs.File) — The child's standard input is f — set_fd(mut c, 0, f). std.process.set_stdout pub fn set_stdout(mut c: Command, f: fs.File) — The child's standard output is f — set_fd(mut c, 1, f). std.process.set_stderr pub fn set_stderr(mut c: Command, f: fs.File) — The child's standard error is f — set_fd(mut c, 2, f). std.process.close_fd pub fn close_fd(mut c: Command, child: int) — Descriptor child is CLOSED in the child — a shell's N<&-. std.process.start pub fn start(c: Command) -> Child ! {unsupported, invalid, not_found, denied, io} — Start c and return the handle of the child, WITHOUT waiting for it. std.process.start_with pub fn start_with(c: Command, inherit: List[net.Listener]) -> Child ! { unsupported, not_found, denied, io, } — Start c with inherit handed down to the child, and answer the child's handle WITHOUT waiting for it — the PARENT half of descriptor inheritance, whose child half is std.net.adopt_listener. std.process.start_job pub fn start_job(c: Command, group: int, defaults: int) -> Child ! { unsupported, invalid, not_found, denied, io, } — s219 ([os.proc.job]): start c as a job. group -1 leaves the child in this process's group, 0 makes it the leader of a new group (whose id is pid(child)), a positive id joins that group — a pipeline's later stages join the first's. std.process.start_foreground pub fn start_foreground(c: Command, group: int, tty: fs.File, defaults: int) -> Child ! { unsupported, invalid, not_found, denied, io, } — start_job, and the job's group takes the terminal tty as its foreground before the program runs (no race: the child does it before exec, the parent again after). std.process.start_session pub fn start_session(c: Command, defaults: int) -> Child ! { unsupported, invalid, not_found, denied, io, } — s290 ([os.proc.session], sc81): start c as the leader of a new session, WITHOUT waiting for it. std.process.pid pub fn pid(ch: Child) -> int ! {io} — The child's operating-system process id (io once it is reaped). std.process.wait_status pub fn wait_status(take ch: Child) -> int ! {io} — s219 ([os.proc.status]): wait, and say how it ended. The exit code (0..255), or -N for a child ended by signal N — the number a shell reports as 128 + N (killed_by reads it). std.process.killed_by pub fn killed_by(status: int) -> int — The signal number a wait_status names, or 0 for an exit. std.process.Status pub struct Status { value: int, } — How a child ended or stopped, as one of three kinds that never meet ([os.proc.poll], [os.proc.status]): an EXIT with its code (0..255), an END BY SIGNAL N (the builtins' -N), or a STOP by signal N (the builtins' 256 + N). std.process.status_from pub fn status_from(value: int) -> Status — The Status a status number reads as: wait_status's answer, or the second half of os_wait_poll's. std.process.is_exited pub fn is_exited(s: Status) -> bool — Whether s is an exit (0..255). std.process.is_signalled pub fn is_signalled(s: Status) -> bool — Whether s is an end by a signal (-N). std.process.is_stopped pub fn is_stopped(s: Status) -> bool — Whether s is a stop (256 + N): the child is alive and waits to be continued. std.process.exit_code pub fn exit_code(s: Status) -> int ! {none} — The exit code of an exit; none for an end by signal, a stop, or a value of no kind. std.process.signal_of pub fn signal_of(s: Status) -> int ! {none} — The host signal number that ENDED the child; none for an exit, a stop, or a value of no kind. std.process.stopped_by pub fn stopped_by(s: Status) -> int ! {none} — The host signal number that STOPPED the child; none for an exit, an end, or a value of no kind. std.process.shell_code pub fn shell_code(s: Status) -> int — What a POSIX shell reports for s as $?: the exit code, or 128 + N for an end by signal N and for a stop by N alike (XCU 2.8.2; a stopped job's $? is dash's 128 + N). std.process.Change pub struct Change { changed: bool, child: Child, status: Status, live: int, } — What one poll found. std.process.poll pub fn poll() -> Change ! {io} — Look, without waiting, for a child of this program's that ended or stopped since it was last looked at ([os.proc.poll], ruling #84): the first such child in the order they were started, reaped if it ended. std.process.wait_status_core pub fn wait_status_core(take ch: Child) -> int ! {io} — s246 ([os.proc.status], ruling #88 R3 = D): wait, and say how it ended, a core included. wait_status's answer — the exit code (0..255), or -N for an end by signal N — except that a child that dumped core (the host's WCOREDUMP) answers -(256 + N), below every end without one. std.process.status_from_core pub fn status_from_core(value: int) -> Status — The Status a core sibling's answer reads as (wait_status_core, poll_core): -(256 + N), an end by signal N that dumped core, is the end by N (-N), so is_signalled, signal_of and shell_code answer for it exactly what they answer for the released wait's -N; every other value reads as status_from reads it. std.process.dumped_core pub fn dumped_core(value: int) -> bool — Whether a core sibling's answer says the host wrote a core: -(256 + N) for a signal number N from 1 to 255, the mirror of a stop's 256 + N. std.process.CoreChange pub struct CoreChange { change: Change, core: bool, } — What one poll_core found: the Change that poll would report, its status read by status_from_core (so every released accessor answers as it does for poll), and core, whether the host wrote a core for the end it reports (dumped_core). std.process.poll_core pub fn poll_core() -> CoreChange ! {io} — s246 ([os.proc.poll], ruling #88 R3 = D): poll, a core included. The same look at every child this program started, without waiting, in the order they were started, with an end that dumped core reported as such — what a shell needs to say "(core dumped)" after a job's words. std.process.Group pub struct Group { id: int, } — A process GROUP: the unit a job is, and what std.signal's send_group reaches (ruling #79 R1: the type is std's, over the builtin tier's group ids). std.process.group_of pub fn group_of(leader: Child) -> Group ! {io} — The group leader leads: a child started with start_job (or start_foreground) and group 0 leads a new group whose id is its process id. std.process.own_group pub fn own_group() -> Group ! {unsupported} — This process's own group — kill 0's, which a send to it reaches this process too ([os.signal.send.group]). std.process.lead_group pub fn lead_group() -> () ! {denied, invalid, io, unsupported} — Make THIS process the leader of a new group of its own, whose id is its process id ([os.term.group], setpgid(0, 0)): what an interactive shell does at start, and what GNU timeout does before it runs its command so that a send to its own group reaches everything the command started. std.process.join_group pub fn join_group(g: Group) -> () ! {denied, invalid, io, unsupported} — Move THIS process into group g of its own session ([os.term.group], setpgid(0, g)): what a shell does at exit to go back into the group it was started in. std.process.lead_session pub fn lead_session() -> () ! {denied, io, unsupported} — s290 ([os.term.session], sc81): make THIS process the leader of a new session, and of a new group in it, both ids its process id (own_session(), own_group().id and std.env.pid() agree after), with no controlling terminal. std.process.own_session pub fn own_session() -> int ! {unsupported} — s290 ([os.term.session], sc81): this process's session id (getsid(0)): its own process id when it leads its session, the leader's otherwise. std.process.wait pub fn wait(take ch: Child) -> int ! {signal, io} — Wait for ch to finish and answer its exit code, consuming the handle. std.process.kill pub fn kill(mut ch: Child) -> () ! {io} — Kill ch — end the child immediately, without reaping it. std.process.run pub fn run(c: Command) -> int ! {unsupported, invalid, not_found, denied, signal, io} — Start c, wait for it, and answer its exit code. std.process.is_success pub fn is_success(exit_code: int) -> bool — Whether exit_code means the program succeeded. std.process.exec pub fn exec(c: Command, env: List[str]) -> () ! {unsupported, invalid, not_found, denied, io} — Replace THIS program with the one c names — an exec, not a spawn. std.process.set_ids pub fn set_ids(uid: int, gid: int, groups: List[int]) -> () ! {denied, invalid, unsupported, io} — Make THIS process another user, for good. std.process.exit pub fn exit(code: int) — End THIS process immediately with code. std.process.exit_signal pub fn exit_signal(meaning: int) -> () ! {invalid, unsupported} — s246 ([os.signal.exit], ruling #88 R2): end THIS process by meaning's signal, so that its parent reads the end as the end by that signal (-N: signal_of, $? 128 + N) — what a wrapper whose command died of a signal does to die of the same one (GNU timeout, where exit(139) would only imitate SIGSEGV). std.process.CoreLimit pub struct CoreLimit { soft: int, hard: int, } — This process's core limit ([os.proc.core]): soft, the size in bytes past which a dump is cut (0: no core file), and hard, the ceiling the soft may be raised to; -1 is unlimited in either. std.process.core_limit pub fn core_limit() -> CoreLimit ! {unsupported} — s253 ([os.proc.core], wolf 0.2.35): this process's core limit, getrlimit(RLIMIT_CORE) as a CoreLimit. std.process.set_core_limit pub fn set_core_limit(soft: int, hard: int) -> () ! {denied, invalid, unsupported} — s253 ([os.proc.core], wolf 0.2.35): set this process's core limit, setrlimit(RLIMIT_CORE), for this process and every child it starts after the call. std.process.core_off pub fn core_off() -> () ! {unsupported} — s253 ([os.proc.core], wolf 0.2.35): this process dumps no core, whatever ends it, on every host and every core pattern. std.process.Fork pub struct Fork { pid: int, child: Child, } — What one fork answered, in the process that reads it (s247, [os.proc.fork]). std.process.fork pub fn fork() -> Fork ! {busy, io, unsupported} — s247 ([os.proc.fork], rulings #90 and #95): make a child process that runs on from this call, a copy of this program. std.process.is_child pub fn is_child(f: Fork) -> bool — Whether a fork's answer is the CHILD's (pid 0).