Module
std.process — build a command as an argument VECTOR, start it — alone, or with a set of listeners handed down to it — wait for its exit code, kill it, and end this process. Stability tier: core.
The PARENT half of descriptor inheritance lives here (start_with, sc39), and the child half is std.net.adopt_listener (sc37). A prefork master binds its listeners once, spawns each worker with the set, and each worker adopts by POSITION — descriptors 3, 4, … in the order given, [os.proc.inherit]. Until sc39 that handshake was written across two tiers, the parent through the builtin and the child through std.net, which is the one thing wolf-std#6's consumer named that was wolf-std's to fix rather than a consumer's to accept (wolf-std#9). **The set is an argument of the SPAWN and never a field of the Command** — the reasoning is on start_with, and it is about lifetime: a listener set belongs to the master and each spawn borrows it.
There is no shell here, and there never will be. The builtin tier takes an argv ARRAY and nothing else (os_spawn(List[str])), so a command is a program name plus its arguments as separate values, all the way down to the host's execve. No string is ever parsed into words, no sh -c exists to parse one, and a file name containing a space, a quote or a ; is therefore just an argument. Injection is off the table by construction rather than by escaping, which is the whole reason this module's builder shape is the ONLY way to spawn: a convenience that took "grep -n {pattern} {path}" would have to invent quoting rules, and every quoting rule anyone has ever written has had a hole in it.
**Capability: Exec (I13).** start, run, wait, kill, exit, exit_signal, fork, poll, wait_status_core, poll_core, lead_group, join_group, start_session, lead_session, set_core_limit and core_off reach the host's process table (own_group, own_session and core_limit read this process's context: env), are tagged exec in the toolchain's sandbox table, and are categorically refused at comptime (D33) — with the sandbox table's own reason, which is worth quoting because it is sharper than "determinism": *compiling a package must never run or terminate programs on the machine that compiles it*. wolf add may not mean arbitrary code executes with the builder's credentials. The refusal is E0701 and tests/process/comptime_refuses.lu holds it one level down, at os_kill, because a comptime fn cannot call across a module boundary at this pin (F-0051) and because os_spawn's List[str] argument is outside the comptime engine's subset — the witness has to be the builtin whose only argument is an int, with its row HANDLED rather than propagated, since ? inside a comptime fn is unsupported and masks the refusal entirely (F-0069). The builder half of this module (command, from_argv, push_arg, argv, is_success) reaches NOTHING and is comptime-safe — in an os module the pure function is the surprising one, so it is spelled out here and on each of them (§14). "Comptime-safe" is a statement about the sandbox and not a promise that you can call it: F-0051 means no comptime fn can call across a module boundary at this pin, so the builder is comptime-safe and comptime-unreachable at the same time — exactly where std.net's address helpers and std.fs's path helpers stand.
Errors are rows, never traps (D30, §14): a program that is not there, a directory that will not execute, a child that died on a signal, a handle that was already reaped — every one of them is an ORDINARY outcome a caller handles with else or propagates with ?. Nothing here traps. The vocabulary is the s40 builtin tier's, adopted verbatim so std adds no translation layer:
- not_found — no such program (and the same tag for an EMPTY argv, which names no program at all) - denied — the host refused to execute it (permissions, a directory, a file with no execute bit) - signal — the child died WITHOUT an exit code: killed, or crashed. Its own outcome and never a fake code, because every fake would collide with a code a program can really return (§12: one tag per failure mode a caller can act on) - io — every other host failure, including a forged, foreign or already-reaped handle, coarsened to one tag because the builtin tier reports one and no caller can act on the difference (§12's rule 3)
**An exit code is an int, and a handle is a TYPE.** The builtin tier hands out two bare integers whose meanings are unrelated — a child handle from os_spawn, an exit code from os_wait — and passing one where the other belongs is the mistake this module exists to make impossible: Child is a struct, so a code can never be waited on and a handle can never be compared with 0. The code itself stays an int, because that is what it is: the number the child returned, in 0..255 on every tier-1 host, with 0 meaning success (is_success says so once so that no caller writes the convention out).
A child's stdio is INHERITED, and this paragraph said the opposite for four sprints. It was headed "the stdio of a child is CLOSED at this pin" and said os_spawn wired all three streams to the host's null device, so nothing a child wrote reached the parent's streams. Measured at sc39 and false: a self-spawned child's print lands in the PARENT's stdout on the native lane, and on the checked lane the child's diagnostics land on the parent's stderr. Both spawn builtins behave this way, with an empty inherit set and with a non-empty one. The claim was never checkable here, because until sc39 no test in this repository ran a child at all (F-0066); tests/process/prefork_handoff.lu is the first, and it is what caught this.
So: a child's output and diagnostics go WHERE THIS PROGRAM'S GO. Its input does not: [os.proc.spawn] wires a child's descriptor 0 to the null device, and the sentence that stood here until s215 ("a child can read this program's input") was never what the clause said. A library that spawns a helper is putting that helper's chatter into its caller's streams — plan for it.
Capture arrived at s215, and it is a map, not a mode. wolf-lang s215 added os_pipe and os_spawn_fds ([os.proc.pipe], [os.proc.fds]): a Command now carries a DESCRIPTOR MAP, built with set_stdin, set_stdout, set_stderr, set_fd and close_fd, and pipe() makes the two std.fs files a map hands down. A pipeline is two commands and a pipe; 2>&1 is one file given to two descriptors; 5<file is set_fd(mut c, 5, f). The map is DATA — a list of (child descriptor, file) pairs the builders keep — so nothing here parses a redirection either: a shell that reads 2>&1 from a script parses it itself and calls the builders. F-0065's capture half closes with this; its other items stay below. Filed upstream as [wolf-lang#256](https://github.com/wolffe-lang/wolf-lang/issues/256): [os.proc] never states the posture, and [os.proc.inherit]'s "descriptors 0, 1 and 2 are the spawn's ordinary stdio" is the only sentence in the spec that touches it — "ordinary" being precisely the adjective that does not decide the question.
Waiting is what reaps, and the handle is consumed by it (§14's handle rule, in its second home). wait(take ch) ends the Child's life exactly as fs.close(take f) ends a File's: a second wait is a static use-after-move rather than a row on every operation for a condition the compiler can see, and tests/process/use_after_wait.lu holds the rejection as fail(E1001). kill does NOT reap — it takes mut ch and leaves the handle alive for the wait that must follow, because a killed child that nobody waits for is a zombie on every unix. A Child a caller FORGES from data (process.Child { slot: 4242 }) answers io, never a trap, for the same reason a missing file does: no field is private at this pin, so a forged handle is a checkable condition rather than a contract violation.
Jobs: the poll, the status and the group (sc64, wolf 0.2.31's s241 and s242, rulings #79 and #84). A shell's children change in three ways, and Status keeps them apart: an exit (0..255), an end by a signal (-N) and a stop (256 + N), which is not an ending — a stopped job is alive and waits for fg or bg. poll looks at every child this program started without waiting and reports the first that ended (reaping it) or stopped; with std.signal's listen and wait on signal.child() it is the wait a trapped signal cuts short. A job is a Group: group_of a leader started with start_job(c, 0, …), own_group this process's, and std.signal.send_group signals every member. lead_group and join_group move THIS process (an interactive shell at start and at exit; GNU timeout before its command).
A core, and the end by a signal (sc66, wolf 0.2.33's s246, ruling #88). The released wait_status and poll answer -N for an end by signal N whether or not the host wrote a core, and Status keeps every answer it gave (R3 = D). A program that must say "(core dumped)" asks the siblings, wait_status_core and poll_core, whose answer for such an end is -(256 + N); status_from_core reads it as the same Status and dumped_core (or CoreChange.core) says there was a core. Which ends dump core is the host's. exit_signal ends THIS process by a signal, so its parent reads the end its command had (R2).
The fork (sc69, wolf 0.2.34's s247, rulings #90 and #95). fork makes a child that runs on from the call, a copy of this program — a shell's subshell, where start runs another program. The parent's answer names the child as a Child every call above serves; the child's says it is the child (is_child) and ends with exit. It is busy while any task is live, so a program forks from main before its first spawn or after every scope has joined; the checked machine and windows answer unsupported, and a program's in-process path runs there.
**The core a process's end may leave (sc72, wolf 0.2.35's s253, [os.proc.core]).** core_limit reads this process's core limit as a CoreLimit (soft and hard, -1 unlimited; read first, the limit it was born with), set_core_limit sets it for this process and every child started after, and core_off makes THIS process dump no core whatever ends it, on every host and every core pattern — GNU timeout's own call before it ends itself by its command's signal (exit_signal). The reader is env (it reads this process's context, with own_group); the set and the off call are exec, with exit_signal.
**A session of its own (sc81, wolf 0.2.39's s290, [os.proc.session], [os.term.session]).** A session is the unit a terminal belongs to: its keys, its hangup and its background stops reach every group of the session that holds it, and nothing outside. start_session starts a child that leads a new session, with no controlling terminal; a server that forks calls lead_session in the child before its exec, which is what sshd does for each command it runs, so no key, hangup or kill 0 of the server's session reaches the command, and none of the command's reaches the server. own_session reads this process's session id. A child that must have a terminal of its own takes it after lead_session, with std.term.open_controlling; std.term's Pty says the whole order.
What is deliberately absent. Each is a reviewed contract with a filing behind it rather than an approximation:
output(c: Command) -> str ! {not_found, denied, signal, io}
stdin_text(mut c: Command, text: str)
A child's whole stdout as a `str`, and text written to its stdin,
as one call each. Buildable since s215 from `pipe` and the map,
and left out on purpose until a consumer needs the convenience:
the only correct `output` reads the pipe WHILE the child runs (a
child that fills a pipe nobody drains blocks forever), which
wants a task, and the first consumer (pelt) does its own
plumbing.
env_for(mut c: Command, name: str, value: str)
current_dir(mut c: Command, path: str)
A child's environment and working directory. `os_spawn` inherits
both from the parent and takes no third argument (F-0065). A
caller that must change them today changes its OWN with
`std.env.set` before spawning, which is a different thing and is
not documented as if it were the same.
try_wait(mut ch: Child) -> int ! {none, signal, io}
Has THIS one finished? Not a per-handle try: since wolf 0.2.31
`poll` (s242, ruling #84) answers "has any child of mine ended or
stopped?" without blocking, and ruling #84 R1 chose that shape
over a try per handle (one call per job per look).
wait_timeout(mut ch: Child, d: Duration)
Same gap as the net tier's deadline (F-0049): no builtin arms one.
pid(ch: Child) -> int
The `Child`'s field is the MACHINE's table index, not the host's
process id, so an accessor named `pid` would name something this
tier does not have. Nothing reports a real pid (F-0065).
signal_of(…) -> int (arrived: `signal_of(Status)`, sc64)
Which signal killed it. `wait`'s `signal` row still carries no
payload; `wait_status` and `poll` answer the number, and
`Status` reads it (an end by signal, apart from a stop).
run_with(c: Command, inherit: List[net.Listener]) -> int ! {…}
`start_with` + `wait`, the way `run` is `start` + `wait`. Absent
because the ONLY reason to hand a listener down is that the child
goes on serving after the parent returns to its loop, and a call
that blocks until the child exits is the opposite of that. `run`
earns its place for the commonest case; this one would have no
case at all, and a convenience nobody can use is surface (sc39).
Lanes, and the paragraph that used to stand here was out of date. It said the checked tier was the only lane that starts a process and that the native rung refused the whole module by name ("process builtins in native lowering (checked lane only at s40)"). Both were true when written and neither is now: **s107 (1b149ba) crossed the process trio natively**, and the ledger has said native = "run" for every file in tests/process/ since. lupin was declined by design at s40 and its conformance pin now carries the whole os family, so not_found_row, forged_handle_io_rows, use_after_wait, exit_code and builder are all THREE-lane today. The stale sentence survived four sprints because prose is what no gauntlet reads (sc38's lesson, one module over); it is corrected here at sc39 against the ledger, which is the artifact that measured.
**start_with is the one function whose lanes are still uneven, and every word of it is a stated posture rather than a gap.** An EMPTY inherit set runs on all three lanes — [os.proc.inherit] makes it os_spawn with the program named apart, served everywhere. A NON-EMPTY set is refused BY NAME by two of them, in one construct string they both print verbatim — *fd inheritance across os_spawn_with in checked execution* — because each is a binary INTERPRETING a program, so a descriptor handed to "the program's child" would be handed to the interpreter's child. That is a whole-program unsupported, not a catchable row, so the non-empty witness is native-only; windows is the host that would answer the catchable unsupported ROW instead, for a different reason again (a SOCKET is not a small stable number a parent can name by position). Three refusals, three reasons, and none of them a calendar.
No doc example in this module starts a real program, and that is a portability statement rather than a shortcut. (Rows do since sc64 — process/poll_job.lu starts /bin/sleep, sc66's process/wait_core_rows.lu /bin/sh — and print their lines for that reason on windows, which has neither; the rest of this paragraph is the record from before them.) There is no program every tier-1 host has (/bin/sh is not on windows, cmd.exe is not on linux) and the directive schema has no per-platform gate — so a spawn test that ran anything real would be red on some supported host. What every witness here uses instead is deterministic on ALL of them: a program name no host has (not_found), an empty argv (not_found again), and a forged handle (io). The happy path — a live child, its exit code, its signal row after a kill — is proven upstream in the toolchain's own unix-gated tests, and this module's inability to witness it here is filed as F-0066 rather than papered over.
One of F-0066's three legs came off at the sc12 pin, and the filing stays open — which is worth stating precisely rather than leaving to be inferred from a closed finding. The filing named the cheapest fix as an os_exe builtin, "which lets a test spawn ITSELF", and s90 landed exactly that (wolf-lang#69: os_exe() -> str ! {io}, the running executable's path, capability Env and comptime-refused beside os_cwd). So the clause "a wolf program cannot learn its own path" is RETIRED: it was true from sc11 to sc12 and it is not true now. The finding is not closed, because its other two legs hold. A self-spawn test would run on the CHECKED lane alone — the native rung still refuses the process trio by name and lupin still declines it by design, both re-measured at this pin — and a program that spawns itself must tell the child from the parent, which needs an argument the child reads back and therefore a second capability inside the child. std wraps os_exe nowhere at this pin: nothing in the library needs it, and a process.exe() whose only caller would be a test this module still cannot write is surface without a use.
Functions and methods
fn · Source line 352
pub fn command(program: str) -> Command
A Command that runs program with no arguments.
Total: no rows, no traps. Pure and comptime-safe — building a command starts nothing. program is a path or a bare name; a bare name is resolved by the HOST's search rules (PATH on every tier-1 platform), which is the host's business and not this module's, and a name it cannot resolve is start's not_found row rather than an error here.
let ls = process.command("ls")
let vec = process.argv(ls)
vec.len == 1
vec[0] == "ls"
fn · Source line 380
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.
Total: no rows, no traps. Pure and comptime-safe. This is the constructor for an argv a program already HAS — std.env.args() forwarded to a child, a vector read from a configuration — and it is why push_arg is not the only way to build one.
An EMPTY vector is accepted here and misses at start with not_found: a vector that names no program is data a program can hold perfectly well, so refusing it at construction would move a run-time outcome into a place that has no row (§2).
var argv = List[str]()
(mut argv).push("grep")
(mut argv).push("-n")
let c = process.from_argv(argv)
let vec = process.argv(c)
vec.len == 2
vec[0] == "grep"
fn · Source line 408
pub fn push_arg(mut c: Command, value: str)
Append one argument to c.
Total: no rows, no traps. Pure and comptime-safe. value is passed to the child as ONE argument whatever it contains — spaces, quotes, newlines and semicolons are ordinary bytes, because nothing between here and the host's execve parses words (the module header's whole subject).
mut c because appending is the operation's point (§3), and the call site spells it. The verb is push_arg rather than arg for two reasons: push is std's vocabulary word for appending to a sequence (§8), and std.env.arg(i) already means "the argument at i" — a program that forwards its own argv to a child imports both modules, and two functions called arg doing opposite things in one file is a collision std declines to create (§1: one concept, one name).
var c = process.command("grep")
process.push_arg(mut c, "-n")
process.push_arg(mut c, "the wolf; rm -rf /")
let vec = process.argv(c)
vec.len == 3
vec[2] == "the wolf; rm -rf /"
fn · Source line 425
pub fn argv(c: Command) -> List[str]
c's argument vector: the program first, then its arguments.
Total: no rows, no traps. Pure and comptime-safe. The list is a copy of what the child would receive, so pushing to it does not extend the command — push_arg is how a command grows.
var c = process.command("wc")
process.push_arg(mut c, "-l")
let vec = process.argv(c)
vec.len == 2
vec[0] == "wc"
fn · Source line 464
pub fn pipe() -> Pipe ! {io}
A new pipe.
Rows: io when the host cannot make one (the process is out of descriptors). Never traps.
Close what you handed down. A child given write holds its own copy; this program's copy is still open after start, and a reader of read never sees eof while any copy is. The pipeline idiom is: make the pipe, start both stages, close this program's two ends, wait.
Capability exec (ruling #54: a pipe exists to wire a child, so os_pipe is charged with the spawn family, not io); refused at comptime (D33). Delegates to os_pipe (wolf-lang s215, [os.proc.pipe]).
A prose example, because a doc example imports exactly the documented module (§4) and the ends are read and written with std.fs: let p = process.pipe()?, fs.write(mut p.write, "howl")?, fs.close(take p.write)?, then fs.read(mut p.read, 64) answers "howl" and the next read eof. tests/process/pipe_round_trip.lu holds exactly that.
fn · Source line 490
pub fn set_fd(mut c: Command, child: int, f: fs.File)
The child gets f as descriptor child — a shell's N<file, N>file 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).
Total: nothing is checked or opened until start. Naming child again replaces the earlier entry, so the last builder call wins, as a shell's last redirection does. A child outside 0..255 is accepted here and is start's invalid row; a closed or forged f is start's io. Pure and comptime-safe — the map is data.
f is READ, not consumed: this program still owns its copy and must close it (see pipe). Descriptors above 2 are served by the compiler's machines on linux and macOS; lupin serves 0, 1 and 2 only and refuses a higher one by name.
A prose example (a File is std.fs's, which a doc example cannot import, §4): with p = process.pipe()?, set_fd(mut c, 5, p.read) on process.command("cat") plus the argument /dev/fd/5 is cat /dev/fd/5 5<&r; wolf-lang's proc_fd_lanes.rs runs that shape.
fn · Source line 495
pub fn set_stdin(mut c: Command, f: fs.File)
The child's standard input is f — set_fd(mut c, 0, f).
fn · Source line 501
pub fn set_stdout(mut c: Command, f: fs.File)
The child's standard output is f — set_fd(mut c, 1, f). With a pipe's write end this is how a caller captures what a child prints.
fn · Source line 507
pub fn set_stderr(mut c: Command, f: fs.File)
The child's standard error is f — set_fd(mut c, 2, f). Given the same file as set_stdout, this is a shell's 2>&1.
fn · Source line 519
pub fn close_fd(mut c: Command, child: int)
Descriptor child is CLOSED in the child — a shell's N<&-. Same rules as set_fd; lupin refuses a close by name.
var c = process.command("ls")
process.close_fd(mut c, 2)
process.argv(c).len == 1
fn · Source line 585
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.
Rows: not_found when no such program exists — and for an EMPTY argv, which names no program at all; denied when the host refuses to execute it; io for every other host failure, and for a File in the descriptor map that is closed or forged. Two rows belong to the map alone and a command without one never raises them: invalid for a map the builders could not make well-formed (a child descriptor outside 0..255), and unsupported where the host places no map — windows, by name. Never traps, and a call that answers invalid, unsupported or the map's io has started nothing.
Without a map the child inherits this process's environment and working directory, and its standard OUTPUT and ERROR: what it writes goes where this program's writes go. Its standard INPUT is the null device — it reads end-of-file at once and never this program's input ([os.proc.spawn]; this doc said "it can read this program's input" until s215, which the clause never did). With a map (set_stdin, set_stdout, set_stderr, set_fd, close_fd) each descriptor it names is what the child gets, and the rest keep that posture — so set_stdout(mut c, p.write) with p = process.pipe()? is how a caller CAPTURES a child's output, F-0065's half that inheriting never was. A started child MUST be waited for — wait(take ch) is what reaps it — or it stays a zombie on every unix until this process exits.
**Why the name is not spawn.** spawn is one of the language's 50 reserved keywords — it opens a task (s.spawn(fn() { … })) and a supervised proc (spawn proc) — so pub fn spawn is E0008 with no raw-identifier escape, exactly as std.fs.copy_file is not copy. The collision is worth more than the name: a child process and a task are different things with different failure models, and a std function that borrowed the keyword's word for the other one would have invited the confusion the type system then has to unpick.
Capability Exec; refused at comptime (D33). Delegates to os_spawn, or to os_spawn_fds (wolf-lang s215, [os.proc.fds]) when the command carries a descriptor map.
var missing = process.command("wolf-sc11-no-such-program-here")
var child = process.start(missing) else |_| { process.Child { slot: -1 } }
(process.wait(take child) else -1) == -1
fn · Source line 706
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.
**The child receives the listeners as descriptors 3, 4, … in the order given**, and that numbering is the whole contract ([os.proc.inherit]). The parent never learns an OS descriptor number and the child never has to be told one out of band: "the listener is 3" is true by position, so a master hands its argv a COUNT and never a descriptor. Descriptors 0, 1 and 2 are the spawn's ordinary stdio — INHERITED from this process, exactly as they are for start — and nothing above 2 + inherit.len is open in the child that the runtime put there. tests/process/prefork_handoff.lu witnesses that upper bound from inside the child: with one listener in the set, descriptor 3 adopts and descriptor 4 answers io.
**The set is on the SPAWN and not on the Command, and that is the one design decision in this function.** It was asked as a question at sc37 and answered from real code by the consumer that needed it (lobo, ws18): a master binds its listeners ONCE and keeps them for its whole life, because a REPLACEMENT worker has to inherit the same socket; it then spawns worker 1, worker 2, … and re-spawns worker 2 after a kill -9. The listener set is a property of the MASTER and each spawn is an EVENT THAT BORROWS IT. A Command that accumulated an inherit set would have to be rebuilt or reset per spawn, and one reused across spawns would silently carry state the second spawn never asked for — a Command that remembers descriptors is a Command that can hand a stale one down. The call-argument shape makes the borrow visible at every site and has no state to get wrong. Pointing the same way: the ORDER of the set IS the contract, and an ordered argument at the call is where a reader looks for that; a builder field is not.
**Why List[net.Listener] and not List[int], when net.wait took the ints.** wait's ready set mixes listeners and streams and wolf has no sum type that can hold both at this pin, so wait had no typed container to take. An inherit set has one: the only thing the child can DO with a handed-down descriptor is net.adopt_listener, so at this pin the set is listeners or it is nothing. Unwrapping to the builtin's List[int] is this function's job rather than the caller's, which is the point of a typed tier. If a future pin grows an adopt for connected sockets, the container question reopens with the sum type — the same language dependency wait is waiting on, and the two should be answered together rather than one at a time.
An EMPTY set is not a special form. start_with(c, List[net.Listener]()) is start(c) with the program named apart from its arguments, served on every host and every tier — including the two that decline the non-empty case. A prefork master that has not bound anything yet, or a caller that just wants the same spawn, writes the empty list and gets an answer rather than an unsupported.
A Command that carries a descriptor map is unsupported here: the listener set and the map are two spawns' contracts, and [os.proc.fds] keeps them apart because a net handle and a file handle are different numbering spaces. Use start for the map.
Rows: unsupported where the host or the tier does not serve a NON-EMPTY set, BY NAME — windows (handle inheritance exists there, but a SOCKET is not a small stable number a parent can name by position) and the CHECKED machine, which refuses it because it is the wolf binary interpreting a program, so a descriptor handed to "the program's child" would be handed to the compiler's child; not_found when no such program exists — and for an EMPTY argv, which names no program at all, raised here rather than delegated because os_spawn_with takes the program apart and an empty vector has none to give; denied when the host refuses to execute it; io for a bad SET as well as for every other host failure. Never traps.
A bad set spawns NOTHING, and the ordering is load-bearing. A forged or closed listener anywhere in inherit, or more than 64 of them, is io BEFORE any child exists: the runtime maps handles to descriptors first, so a caller that gets io from this call knows no program was started and has nothing to reap. tests/process/start_with_inherit_rows.lu witnesses exactly that, with a forged listener and a program name no host has — the row is io and not not_found, which is the mapping happening first.
What the parent keeps. Handing a listener down does not consume it and does not close it: inherit is READ, the master's listeners are still the master's after the call, and a master serving N workers hands the same Listener to each spawn in turn. The child's copy is a separate descriptor that the CHILD owns from its adopt_listener on — net.close_listener there closes the inherited fd and does not unlink an AF_UNIX path, because the path belongs to the process that bound it.
A started child MUST be waited for — wait(take ch) is what reaps it — exactly as for start.
Capability Exec; refused at comptime (D33). Delegates to os_spawn_with.
A prose example, because a doc example imports exactly the documented module (§4) and cannot reach std.net to bind a listener. A prefork master binds once, then spawns each worker with the set: let srv = net.listen(net.loopback(8080))?, build workers as a List[net.Listener] holding srv, and let w = process.start_with(cmd, workers)? — the worker reads net.adopt_listener(3)? and accepts. tests/process/start_with_empty_rows.lu and tests/process/start_with_inherit_rows.lu are the witnesses.
fn · Source line 757
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. defaults is a set of std.signal meanings set back to the default in the child: a shell that ignores quit() for itself passes it, so its children do not inherit the ignore. Everything else is start's, the descriptor map included.
fn · Source line 773
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). Take the terminal back with term.set_foreground(tty, term.group()) when the job ends.
fn · Source line 830
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. The child's session id, group id and process id are one number (pid(child), and group_of(child) names its group). The spawn itself gives it no controlling terminal; defaults and the descriptor map are placed as start_job places them. This describes the child before exec, not what the program may do afterwards. Nothing of this process moves: its session, group and terminal stay as they were.
A terminal is not given here. A pty's slave in the map (set_stdin, set_stdout, set_stderr) is a terminal on those descriptors, but the map itself never makes it controlling. A program may take that terminal after exec: bash does in this shape, dash does not. If it does, closing the last master can hang up its session. Do not infer the running program's terminal state from the spawn map. A server that requires a controlling terminal forks, calls lead_session and std.term.open_controlling in the child, then execs (std.term.Pty says the order).
Rows, in start_job's order: not_found for an empty argv (decided here, on every host); invalid for a map the builders could not make well-formed (a child descriptor outside 0..255) and a defaults bit outside the meanings, before the host; unsupported on windows, which has no sessions of this kind; io for a closed or forged file in the map; then the program's not_found, denied and io, with the host's number in os_error(). Never traps, and a row starts nothing. A started child MUST be waited for, as start's.
Capability Exec; refused at comptime (D33). The checked machine spawns through its own path, its child taking the same first step. lupin 0.1.61 answers the shape rows and refuses a well-formed spawn by name (Rust's standard library has no stable new-session spawn). Delegates to os_spawn_session.
var c = process.command("wolf-sc81-no-such-program-here")
process.close_fd(mut c, 300)
var row = "started"
var ch = process.start_session(c, 0) else |e| {
row = "{e}"
process.Child { slot: 0 - 1 }
}
row == "invalid"
(process.wait(take ch) else -1) == -1
fn · Source line 843
pub fn pid(ch: Child) -> int ! {io}
The child's operating-system process id (io once it is reaped).
fn · Source line 850
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). Reaps, as wait.
fn · Source line 855
pub fn killed_by(status: int) -> int
The signal number a wait_status names, or 0 for an exit.
fn · Source line 889
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. Pure and comptime-safe; any int is accepted (see Status on a value of no kind).
process.is_exited(process.status_from(3)) == true
process.is_signalled(process.status_from(-9)) == true
process.is_stopped(process.status_from(275)) == true
fn · Source line 899
pub fn is_exited(s: Status) -> bool
Whether s is an exit (0..255). Pure.
process.is_exited(process.status_from(0)) == true
process.is_exited(process.status_from(275)) == false
fn · Source line 909
pub fn is_signalled(s: Status) -> bool
Whether s is an end by a signal (-N). Pure.
process.is_signalled(process.status_from(-15)) == true
process.is_signalled(process.status_from(15)) == false
fn · Source line 921
pub fn is_stopped(s: Status) -> bool
Whether s is a stop (256 + N): the child is alive and waits to be continued. Pure.
process.is_stopped(process.status_from(256 + 19)) == true
process.is_stopped(process.status_from(19)) == false
process.is_stopped(process.status_from(512)) == false
fn · Source line 932
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. Pure.
(process.exit_code(process.status_from(7)) else -1) == 7
(process.exit_code(process.status_from(256 + 7)) else -1) == -1
fn · Source line 946
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. Pure.
(process.signal_of(process.status_from(-9)) else 0) == 9
(process.signal_of(process.status_from(256 + 9)) else 0) == 0
fn · Source line 960
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. Pure.
(process.stopped_by(process.status_from(256 + 20)) else 0) == 20
(process.stopped_by(process.status_from(-20)) else 0) == 0
fn · Source line 977
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). A value of no kind answers itself. Pure.
process.shell_code(process.status_from(1)) == 1
process.shell_code(process.status_from(-9)) == 137
process.shell_code(process.status_from(256 + 20)) == 148
fn · Source line 1042
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. One waitpid(pid, WNOHANG | WUNTRACED) per live child and never the host's "any child", so a child this program did not start through start, start_with, start_job or start_foreground is never touched. A continue is not reported; each stop is reported once.
The wait a signal cuts short is this and std.signal, with no new call: listen for signal.child() and the meanings the program traps, poll until changed is false, then signal.wait (or signal.wait_fd at a prompt) on that set. signal.child() arrives for a stop and for an end, so the wait ends when a child changes or a trapped signal comes, and an idle program makes no context switch.
Rows: io for a child the host reaped behind the table's back (this program ignores signal.child()), once, its handle closed. Never traps, never blocks — except behind a blocking wait or wait_status on another task, which holds the table until its child ends ([os.proc.poll]'s one lock). windows has no stops: the poll answers ends and live. lupin answers changed false and live 0 while it holds no live child, and refuses by name once it does (it cannot see a stop).
Capability Exec (it reaps, with wait_status); refused at comptime (D33). Delegates to os_wait_poll (wolf-lang s242).
let c = process.poll() else |_| { process.Change { changed: true, child: process.Child { slot: -1 }, status: process.status_from(512), live: -1 } }
c.changed == false
c.live == 0
fn · Source line 1079
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. Read it with status_from_core, whose Status every released accessor reads exactly as it reads wait_status's answer, and dumped_core. Reaps, as wait.
wait_status is unchanged and answers -N, core or not, so a program that compares with -N reads every host alike: which ends dump core is the host's. A pattern that pipes cores to a program (systemd-coredump) dumps one whatever ulimit -c says, a file pattern only where the limit allows, and windows never.
Rows: io for a forged or reaped handle. Never traps. Capability Exec; refused at comptime (D33). The checked machine answers it as the runtime does, and so does lupin 0.1.55 (is77, wolf-interp#263: an exit and a forged handle measured). Delegates to os_wait_status_core.
var forged = process.Child { slot: 4242 }
(process.wait_status_core(take forged) else -1) == -1
fn · Source line 1096
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. Whether there was a core is dumped_core's. Pure and comptime-safe.
(process.signal_of(process.status_from_core(-267)) else 0) == 11
process.shell_code(process.status_from_core(-267)) == 139
process.status_from_core(-11).value == -11
process.status_from_core(256 + 19).value == 275
fn · Source line 1114
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. False for every value the released calls answer (an exit, -N, a stop) and for a value of no kind. Pure and comptime-safe.
process.dumped_core(-267) == true
process.dumped_core(-11) == false
process.dumped_core(-256) == false
process.dumped_core(256 + 11) == false
fn · Source line 1150
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. poll is unchanged. A program uses one or the other for a child: the poll that reports an end reaps it, so a second call could not ask afterwards.
Rows: poll's (io once for a child the host reaped behind the table's back). Never traps, never blocks but behind a blocking wait on another task. Capability Exec; refused at comptime (D33). The checked machine answers it as the runtime does. lupin 0.1.55 answers the poll with no child as poll does and refuses one with a live child by name, since its host has no stop to report (std's try_wait; is77, wolf-interp#263). Delegates to os_wait_poll_core.
let c = process.poll_core() else |_| { process.CoreChange { change: process.Change { changed: true, child: process.Child { slot: -1 }, status: process.status_from(512), live: -1 }, core: true } }
c.change.changed == false
c.change.live == 0
c.core == false
fn · Source line 1204
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. A child that JOINED a group (a positive group) is in the group its caller named, which the caller already holds as a Group { id: … }; one started in this process's group is in own_group().
Rows: io once leader has been reaped (its id may since be another's). Never traps. Delegates to os_proc_pid.
let g = process.group_of(process.Child { slot: 4096 }) else |_| process.Group { id: -1 }
g.id == -1
fn · Source line 1215
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]). Rows: unsupported on a host without groups (windows). lupin declines by name, so the example is prose: signal.send_group(process.own_group()?, m) is kill -m 0.
Capability env (process context, as term.group, ruling #70 R8); refused at comptime (D33). Delegates to os_pgid.
fn · Source line 1234
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. It acts on the caller only: a child's group is set when it starts (start_job), never after.
Rows: denied for a session leader, which may not move (a shell started as one already leads its group); unsupported on windows; io otherwise. Never traps. lupin declines by name, so the example is prose: after process.lead_group()?, process.own_group()?.id is this process's id.
Capability Exec (ruling #79 R6); refused at comptime (D33). Delegates to os_set_pgid(0).
fn · Source line 1257
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. Joining the group it is already in changes nothing; group 0 is lead_group.
Rows, in the order they are decided: invalid for a negative id or one wider than a process id (before the host); unsupported on windows; denied for a session leader, and for a group of another session or one that does not exist; io otherwise. Never traps. lupin answers the invalid rows and declines a well-formed call by name.
Capability Exec; refused at comptime (D33). Delegates to os_set_pgid.
var refused = false
process.join_group(process.Group { id: -2 }) else |_| { refused = true }
refused == true
fn · Source line 1289
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. The terminal it had stops being its controlling terminal for every thread at once: its keys, its hangup and its background stops reach the process no more, and /dev/tty does not open. Every descriptor, the terminal's mode and a registered term.restore_at_exit stay.
Who may call it. A process that leads a group may not (a session leader included): denied, and nothing has moved. So the call is made where the process leads no group: in the child of fork, which never leads one — the server's order, fork then lead_session then the exec, as sshd runs each command — or in a child started in its parent's group. A child that must have a terminal of its own opens it after this call (std.term.open_controlling).
Rows: unsupported on windows; denied for a group leader (the host's EPERM, 1 in os_error()); io for any other refusal (no host was seen to make one). Never traps. The checked machine moves the wolf process, the process the program runs as. lupin 0.1.61 refuses the call by name (Rust's standard library has no setsid). The example is prose, since a call that succeeds moves the process that runs it: in a fork's child, process.lead_session()? and then process.own_session()? == env.pid().
Capability Exec, with lead_group; refused at comptime (D33). Delegates to os_setsid.
fn · Source line 1309
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. A session id is compared, never passed: no call takes one, so it is an int (a Group is a type because std.signal.send_group takes one).
Rows: unsupported on windows. Never traps. The checked machine reads the wolf process's session. lupin 0.1.61 refuses the call by name.
Capability env (process context, with own_group); refused at comptime (D33). Delegates to os_sid.
let s = process.own_session() else -1
s > 0 || s == -1
fn · Source line 1335
pub fn wait(take ch: Child) -> int ! {signal, io}
Wait for ch to finish and answer its exit code, consuming the handle.
Rows: signal when the child died without an exit code — killed by this program or by anything else, or crashed — which is an OUTCOME with no number rather than a failure to report a number; io when the handle is forged, foreign or already reaped. Never traps.
This blocks until the child finishes. There is no deadline at this pin (F-0065): a caller who cannot afford to wait forever looks without waiting instead (poll, from wolf 0.2.31), or kills the child from another task.
take ch because waiting REAPS: the child is gone from the machine's table afterwards, so a second wait is a use-after-move the compiler rejects rather than an io row at run time (§14's handle rule).
Capability Exec; refused at comptime (D33). Delegates to os_wait.
var forged = process.Child { slot: 4242 }
(process.wait(take forged) else -1) == -1
fn · Source line 1363
pub fn kill(mut ch: Child) -> () ! {io}
Kill ch — end the child immediately, without reaping it.
Rows: io when the handle is forged, foreign, already reaped, or names a child that has already exited (a child that is finished is not yours to kill any more). Never traps.
A killed child still has to be waited for. This call does not consume the handle, and the wait that follows answers the signal row rather than a code — that pair is the whole "stop it" idiom, and skipping the wait leaves a zombie on every unix. The kill is immediate and uncatchable by the child: nothing here asks a program to shut down politely, because no builtin sends a gentler signal (F-0065).
mut ch because killing changes what the child IS, exactly as std.fs.read takes mut for advancing a position: the handle's fields do not move, the thing it names does (§14).
Capability Exec; refused at comptime (D33). Delegates to os_kill.
var forged = process.Child { slot: 4242 }
process.kill(mut forged) else |_| { }
(process.wait(take forged) else -1) == -1
fn · Source line 1388
pub fn run(c: Command) -> int ! {unsupported, invalid, not_found, denied, signal, io}
Start c, wait for it, and answer its exit code.
Rows: the union of start's and wait's — unsupported, invalid, not_found, denied, signal, io, each meaning exactly what it means there. Never traps.
This is the whole operation for the commonest case, where a program runs another program and cares only how it ended. It blocks for as long as the child runs, it reaps the child (so nothing is left behind), and it cannot be interrupted at this pin. It gives you the child's output only through a map: run blocks until the child exits, so a child that fills a pipe nobody is reading blocks with it — capture with start, read the pipe, then wait.
Capability Exec; refused at comptime (D33). Delegates to os_spawn and os_wait.
let missing = process.command("wolf-sc11-no-such-program-here")
(process.run(missing) else -1) == -1
fn · Source line 1410
pub fn is_success(exit_code: int) -> bool
Whether exit_code means the program succeeded.
Total: no rows, no traps. Pure and comptime-safe. Zero is success and everything else is failure, on every tier-1 host; this function exists so that the convention is written down once, in std, instead of as a == 0 in every caller that would then have to be re-read when someone wonders whether this platform is the exception. It is not.
The signal row is NOT a code and never reaches here: a child that died without exiting did not succeed and did not fail with a number, which is exactly why it is a separate outcome (§12).
process.is_success(0) == true
process.is_success(1) == false
process.is_success(-1) == false
fn · Source line 1452
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.
The process stays (its id, its parent, its controlling terminal) and its program goes: the new one receives c's whole argument vector (element 0 is both the program to find and the name it is handed), env as its ENTIRE environment — NAME=VALUE entries, the shape std.env.vars() answers, so env.vars() passed through keeps the current environment and an empty list starts from none — and c's descriptor map (set_fd, set_stdin, …, close_fd) applied to this process's own descriptors. One difference from start: a descriptor the map does not name keeps what this process has, so an exec'd program reads this program's standard input (a child started with start reads the null device). Every file this program opened and did not map is closed by the exec.
A program name without a / is searched along the PATH entry of env, or /usr/bin:/bin when env has none — the new program's search path, decided from the call's own arguments, not from this process's environment.
On success this function does not return. A call that returns has failed, and its row says how: invalid for an empty vector, an env entry with no = or an empty name, or a map start would refuse; unsupported on a host with no exec (windows), by name; io for a map naming a closed file; not_found when no program is found; denied when the one found may not be run. A failed exec leaves this process as it was, its descriptors included.
Capability Exec; refused at comptime (D33). Delegates to os_exec (wolf-lang s225, [os.proc.exec]). lupin serves descriptors 0, 1 and 2 in the map and refuses any other by name, as it does for start.
var refused = false
let none = process.from_argv(List[str]())
process.exec(none, List[str]()) else |_| { refused = true }
refused == true
fn · Source line 1496
pub fn set_ids(uid: int, gid: int, groups: List[int]) -> () ! {denied, invalid, unsupported, io}
Make THIS process another user, for good.
**s236 ([os.proc.ids.set]).** After it the process is user uid, group gid, with exactly the supplementary groups groups — its real, effective and saved ids all, in every thread. It is what su, login and a server that has bound its low port do, and it is one call because the three changes have one safe order (the groups, the group ids, the user ids) that a program must not be able to get wrong: the other order leaves the old group and the old groups behind. There is no way back, no "leave this one" word, and no temporary form; do what needs the old user first. The numbers come from the account files: std.os.users reads them.
It returns in one of two states and no other — every id as asked, or every id as it was. A refusal before anything changed is a row; a refusal after a change is put back and read back before it is a row; and if that cannot be done, or the ids read back are not the ones asked for, or an old id can still be taken, the process ENDS (one line on standard error and an abort) rather than run as partly one user and partly another.
Rows: invalid for an id outside 0..=4294967294 or more than 65536 groups (decided before the host), and for an id the host has no mapping for; denied for a process that may not change its ids; unsupported on every host but linux, by name (macOS has no way to read a drop back); io otherwise. Never traps.
Capability Exec; refused at comptime (D33). Delegates to os_set_ids (wolf-lang s236). lupin answers the invalid rows and declines a well-formed call by name.
var refused = false
process.set_ids(0 - 1, 0, List[int]()) else |_| { refused = true }
refused == true
fn · Source line 1524
pub fn exit(code: int)
End THIS process immediately with code.
Never returns — no defer runs, no buffer is flushed by std, and no row can be raised by a call that does not come back. Not a trap: the process ends with the status the caller asked for, which is the one thing a trap cannot do.
Only the low byte of code survives on a unix host: the exit status a parent can observe is code modulo 256, so exit(300) is seen as 44 and exit(-1) as 255. std does not renumber or clamp — a caller that wants a portable status writes one in 0..255, and this sentence is where that is documented rather than discovered.
Capability Exec; refused at comptime (D33) — a comptime program that could end the compiler is the sharpest case of that rule. Delegates to os_exit, which is the one member of the s40 exec family every rung executes: this function therefore runs under the interpreter too, and the only reason it is dark on the native rung is that lowering refuses the whole MODULE for the process trio beside it.
process.is_success(0) == true
process.exit(0)
fn · Source line 1562
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). meaning is in the SENDING shape: one meaning of std.signal's table, or a host number (signal.host(n)). On unix the signal is set back to its default (the runtime's stack guard and any listen let go of it), unblocked and raised on the calling thread; the end is the host's, with a core where the host writes one. A process the signal does not end — a meaning whose default does nothing (child(), continued(), urgent(), resize()), or a stop that is later continued — exits with **128 + N**, so the call returns only a row.
Rows: invalid for 0, for anything signal.send refuses (two meanings, a bit no release publishes, a host number past signal.last()), and from wolf 0.2.35 for the C library's own numbers (signal.host's doc: glibc's 32 and 33, which 0.2.33 and 0.2.34 ended by as exits 160 and 161); then unsupported on windows. Those are its only returns. As with exit, no defer runs and std flushes nothing. std.signal.raise is unchanged (it delivers one listenable meaning).
Capability Exec, with exit; refused at comptime (D33). The checked machine refuses it by name after the shape (it runs inside the wolf process, which a signal would end); lupin 0.1.55 answers the shape rows and refuses a well-formed end by name, since it has no sigaction and no raise(3) (is77, wolf-interp#261). Delegates to os_exit_signal.
var row = "ended"
process.exit_signal(0) else |_| { row = "refused" }
row == "refused"
fn · Source line 1594
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. Read before the program sets it, it is the limit the process was born with. The soft is at most the hard, and an unlimited hard admits any soft.
Rows: unsupported on windows, which keeps no core limit. Never traps. The checked machine reads the wolf process's own limit (the process the program runs as). lupin resolves the call from 0.1.59 (wolf-interp#277).
Capability env (it reads this process's context, with own_group); refused at comptime (D33). Delegates to os_core_limit.
let l = process.core_limit() else |_| process.CoreLimit { soft: 0, hard: 0 }
l.hard == 0 - 1 || (l.soft >= 0 && l.soft <= l.hard)
l.soft >= 0 - 1
fn · Source line 1625
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. Each of soft and hard is -1 (unlimited) or a size in bytes; the soft is at most the hard.
Rows, in the order they are decided: invalid unless each is -1 or 0 and up and the soft is at most the hard (an unlimited soft under a finite hard included), before the host; then unsupported on windows; then denied where the host refuses a raise of the hard limit — a process may lower its hard limit and, without the privilege for it, never raise it again. Nothing changes on a row. Never traps. The checked machine sets the wolf process's own limit. lupin resolves the call from 0.1.59 (wolf-interp#277).
Capability Exec (with exit_signal); refused at comptime (D33). Delegates to os_set_core_limit.
var row = "set"
process.set_core_limit(5, 4) else |_| { row = "refused" }
row == "refused"
let l = process.core_limit() else |_| process.CoreLimit { soft: 0 - 1, hard: 0 - 1 }
var same = "set"
process.set_core_limit(l.soft, l.hard) else |_| { same = "refused" }
same == "set" || same == "refused"
fn · Source line 1658
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. On linux it sets the process's "dumpable" attribute to 0 (prctl(PR_SET_DUMPABLE, 0)), the one switch a pattern that pipes cores to a program obeys (core(5): the limit is not enforced there), and GNU timeout's own call before it ends itself by its command's signal; elsewhere it sets the soft core limit to 0, keeping the hard. So core_off then exit_signal(signal.segment_fault()) is an end by that signal with no core: a parent's wait_status_core answers -11, not -(256 + 11).
The attribute is this process's alone: exec sets it back, so a child it starts dumps as the host says, and no call sets it back here. It has two other effects on linux (PR_SET_DUMPABLE(2const)): the process's /proc/<pid> files become the super-user's, and another process of the same user can no longer ptrace it.
Rows: unsupported on windows. Never traps. The checked machine sets the wolf process's own attribute. lupin resolves the call from 0.1.59 (wolf-interp#277).
Capability Exec (with exit_signal); refused at comptime (D33). Delegates to os_core_off.
var off = "off"
process.core_off() else |_| { off = "unsupported" }
off == "off" || off == "unsupported"
fn · Source line 1718
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. The call answers twice: in the parent a Fork naming the child, in the child a Fork whose pid is 0 (is_child). It is what a shell's subshell is — ( … ), { …; } &, a command substitution, a pipeline stage the shell runs itself — where start runs another program.
What the child is: ONE thread, the caller's, with the program's memory as it was at the call; every descriptor shared, offsets included (a pipe made before the fork carries the child's bytes to the parent); the signal dispositions and the mask kept, nothing pending, a listen's queue its own; no task, no worker, and no child of the parent's (a handle the parent held answers io there). The child ends with exit or exit_signal: a return from the function that forked runs on into the rest of the parent's code.
**The fork's rule is busy**, answered before the host is asked: from a task or a proc handler, while any task is live anywhere in the process (queued, running or parked), and under the deterministic scheduler. So only main's thread forks, before its first spawn or after every scope has joined, and no lock another thread holds is ever copied.
Rows: busy as above; io where the host refuses (a process limit, memory), its number in os_error(); unsupported on windows, which has no fork, and on the checked machine on every host (ruling #95 R4 C), which is the wolf process interpreting the program — so a program with an in-process path takes it there and runs to its end, as on windows. Never traps. lupin 0.1.56 refuses the call by name on unix (std has no fork) and answers windows' unsupported (0.1.55 did not resolve it, wolf-interp#269). The cost, measured upstream: 1,000 forks that end at once and are waited for take 0.119 s on kasumi (dash's x=$(true) 0.083 s).
Capability Exec; refused at comptime (D33). Delegates to os_fork.
let f = process.fork() else |_| process.Fork { pid: 0 - 1, child: process.Child { slot: 0 - 1 } }
if process.is_child(f) { process.exit(0) }
var ch = process.Child { slot: f.child.slot }
let st = process.wait_status(take ch) else 0 - 1
(f.pid > 0 && st == 0) || (f.pid == 0 - 1 && st == 0 - 1)
fn · Source line 1730
pub fn is_child(f: Fork) -> bool
Whether a fork's answer is the CHILD's (pid 0). Pure and comptime-safe.
process.is_child(process.Fork { pid: 0, child: process.Child { slot: 0 - 1 } }) == true
process.is_child(process.Fork { pid: 4242, child: process.Child { slot: 0 } }) == false