Module
std.signal — what a signal does to this process, and hearing one as an event. Stability tier: core. The facade over wolf-lang's [os.signal] family (s114, s188, s219, s232).
A signal is named by its MEANING, never its number ([os.signal.set]): reload() is SIGHUP, interrupt() is the terminal's Ctrl-C, and a set is the bitwise OR of meanings — signal.interrupt() | signal.quit(). The meanings are functions here, each answering its bit, as they were written before std carried a constant (sc72's WAIT_WRITE is the module's one, and it is not a meaning). Twenty are LISTENABLE — every signal POSIX names that a program may catch (reload() … file_limit()), the ones a set may hold. Eight more are SEND-ONLY (kill(), stop() and the six fault signals): send and number take them, and so do ignore_one, reset_one and std.process.exit_signal (s246; the two _one calls refuse kill() and stop(), which no process can ignore). No set-taking call does.
A meaning's bit never changes, and a program never writes one ([os.signal.set.stable]). Every meaning a release has published keeps its bit forever — it is never reassigned or reused, even if the meaning is retired — and a new meaning takes the lowest bit no release has published. So a set stored by one release means the same to the next, and the only spelling of a meaning that is portable is its NAME: call the function, never write the bit and never a host's signal number. number is the one way from a meaning to the number this host gives it (USER is 10 on linux and 30 on macOS), for the places a number is the interface — kill -l, trap … 13, 128 + N.
Three dispositions, nothing else. A meaning's signal either does what the host does by default (reset), nothing (ignore), or arrives as an event (listen, then wait or poll). There is no handler: no wolf code ever runs when a signal arrives ([os.signal.model]). The last call for a meaning wins. ignore and reset take a SET of listenable meanings; ignore_one and reset_one (s246, ruling #88 R1) take ONE meaning in the sending shape — a send-only one such as segment_fault(), or a host number host(n) — which is how a program ignores what it is about to send its own group (GNU timeout -s SEGV).
What a child inherits is what exec leaves ([os.signal.disp]): an ignored meaning stays ignored in every child, a listened one is the default there. That is why a shell LISTENS for interrupt() rather than ignoring it — it survives Ctrl-C and its sleep still dies of it — and why std.process.start_job takes the meanings to set back to default in a child the shell ignores for itself.
Errors are rows, and one shape rule reads every set (s232). An empty set, or one holding any bit that is not a listenable meaning, is io from listen, wait, wait_fd, wait_fds, poll, ignore and reset, and nothing changes; raise takes exactly one listenable meaning. On windows only the first four meanings can be listened for — the console sends terminate() and quit(), and reload() and upgrade() arrive only by this process's own raise — so a listen for any of the other sixteen is io there, and ignore, reset, ignored, send, number, wait_fd, wait_fds, send_group, send_all, text, last, realtime, ignore_one and reset_one answer unsupported, send to text, wait_fds and the two _one calls after their own shape ([os.signal.platform]).
Groups and host numbers (s241, ruling #79). send reaches one process; send_group reaches every member of a std.process.Group (a job), and send_all every process this one may signal, each by its own name so that no miscomputed pid becomes a group or a broadcast. A signal the table gives no meaning (the real-time range, linux IO and PWR, macOS INFO) is sent by its host number, host(n), with last() and realtime() saying which numbers this host has; text is a signal's words. The rows are the host's, kept rather than evened out (R3).
**Capability: exec (I13)** — signal control is process control: listen, wait, wait_fd, wait_fds, poll, ignore, reset, ignore_one, reset_one, raise, send, send_group and send_all are tagged exec in the sandbox table. ignored READS this process's context and is env (ruling #70 R8, with os_pgid); number, last, realtime and text read the host's table and charge nothing (ruling #79 R6). All of them are refused at comptime (D33). The meaning functions and host reach nothing and are comptime-safe.
Functions and methods
fn · Source line 91
pub fn reload() -> int
Re-read configuration (SIGHUP).
fn · Source line 94
pub fn terminate() -> int
Shut down now (SIGTERM).
fn · Source line 97
pub fn quit() -> int
Shut down after draining (SIGQUIT; the terminal's Ctrl-\).
fn · Source line 100
pub fn upgrade() -> int
Swap in a new binary (SIGUSR2).
fn · Source line 103
pub fn interrupt() -> int
The terminal's interrupt character, Ctrl-C (SIGINT).
fn · Source line 106
pub fn suspend() -> int
The terminal's suspend character, Ctrl-Z (SIGTSTP).
fn · Source line 109
pub fn bg_read() -> int
A background process group read the terminal (SIGTTIN).
fn · Source line 112
pub fn bg_write() -> int
A background process group wrote to, or set, the terminal (SIGTTOU).
fn · Source line 115
pub fn child() -> int
A child stopped or ended (SIGCHLD).
fn · Source line 118
pub fn user() -> int
Another program's own signal (SIGUSR1; upgrade() is SIGUSR2).
fn · Source line 121
pub fn alarm() -> int
A timer ran out (SIGALRM).
fn · Source line 126
pub fn broken_pipe() -> int
A write to a pipe or socket nobody reads (SIGPIPE). Ignored, the write is an io row instead of this process's end, and every child starts with it ignored too ([os.signal.disp]).
fn · Source line 129
pub fn abort() -> int
The process was asked to abort (SIGABRT).
fn · Source line 134
pub fn continued() -> int
The process was continued after a stop (SIGCONT). The table's name is CONTINUE; continue is a keyword, so the function says what happened.
fn · Source line 137
pub fn resize() -> int
The terminal's window changed size (SIGWINCH).
fn · Source line 140
pub fn urgent() -> int
Out-of-band data arrived on a socket (SIGURG).
fn · Source line 143
pub fn virtual_alarm() -> int
A user-time timer ran out (SIGVTALRM).
fn · Source line 146
pub fn profile_alarm() -> int
A profiling timer ran out (SIGPROF).
fn · Source line 149
pub fn cpu_limit() -> int
The CPU-time limit was passed (SIGXCPU).
fn · Source line 152
pub fn file_limit() -> int
The file-size limit was passed (SIGXFSZ).
fn · Source line 161
pub fn kill() -> int
End the process now; it cannot be caught or ignored (SIGKILL). Send-only.
fn · Source line 165
pub fn stop() -> int
Stop the process; it cannot be caught or ignored (SIGSTOP). Send-only; continued() is what starts it again.
fn · Source line 168
pub fn segment_fault() -> int
An invalid memory reference (SIGSEGV). Send-only.
fn · Source line 172
pub fn bus_error() -> int
An access to an undefined part of a memory object (SIGBUS). Send-only.
fn · Source line 175
pub fn arithmetic() -> int
An erroneous arithmetic operation (SIGFPE). Send-only.
fn · Source line 178
pub fn illegal() -> int
An illegal instruction (SIGILL). Send-only.
fn · Source line 181
pub fn breakpoint() -> int
A trace or breakpoint trap (SIGTRAP). Send-only.
fn · Source line 184
pub fn bad_syscall() -> int
A bad system call (SIGSYS). Send-only.
fn · Source line 188
pub fn listen(set: int) -> () ! {io}
Hear every meaning in set as an event (os_signal_listen); ends an ignore of them.
fn · Source line 193
pub fn wait(set: int) -> int ! {io}
Park until a meaning in set arrives; that meaning.
fn · Source line 224
pub fn wait_fd(f: fs.File, set: int) -> int ! {unsupported, io}
Wait until the file f names has something to read or a meaning in set is delivered ([os.signal.wait.fd]): the meaning, taken off the queue as wait takes it, or 0 when f is ready — a byte, the end of input or a hang-up — with nothing read, so the read that follows says which. A meaning wins when both are ready; one delivered or pending before the call is answered at once. The meanings must be listened for first (listen). Any readable descriptor serves: a terminal, a pipe, a file (spelling ruled #82, the family's).
This is the wait an interactive program blocks in instead of a read: a delivered signal never tears a read, so an editor reading keys would learn of a resize or a kill only when the next key came. It has no deadline (wait_fds, from wolf 0.2.34, has one and waits on several files); on a terminal with canonical off, std.term's Mode.min and Mode.time time the read that follows.
Rows: io for a set the shape rule refuses — empty, or holding a bit that is not a listenable meaning — before anything else; then unsupported on windows; then io for a closed or forged handle. Never traps. lupin answers the shape rows and declines a well-formed call by name (it has no poll).
Capability exec (signal control, with wait); refused at comptime (D33). Delegates to os_signal_wait_fd. The example is prose, since a handle comes from std.fs: an editor listens for signal.resize(), then loops on signal.wait_fd(tty, set)?, redrawing on a meaning and reading a key on 0.
fn · Source line 302
pub fn wait_fds(files: List[fs.File], set: int, deadline_ms: int) -> Wake ! { invalid, io, unsupported, }
**s248 ([os.signal.wait.fds], ruling #93 R2 A): one wait over several files, a set of meanings and a deadline** — what an editor's loop is: the terminal, its jobs' pipes and its signals, with a timer (the 25 ms that tells a lone ESC from an escape sequence, the 50 ms of a capability probe). Parks until a meaning in set is delivered (Wake { meaning: m, ready: -1 }, taken as wait takes it), or one of files has something to read — a byte, the end of input, a hang-up — (Wake { meaning: 0, ready: i }, i the lowest such index, nothing read), or deadline_ms milliseconds pass (Wake { meaning: 0, ready: -1 }). A meaning wins over a ready file, which stays ready for the next wait; among files the earlier wins, so put the one served first first. deadline_ms 0 looks once and never parks, -1 never passes, any other is measured on the monotonic clock and never answered early. An empty list waits on the set and the deadline alone. A meaning delivered or pending before the call is answered at once. wait_fd(f, set) is this call's one-file case with no deadline.
Rows, in the order they are decided: io for a set the shape rule refuses (empty, a send-only meaning, a bit that is no meaning); then invalid for a deadline below -1; then unsupported on windows; then io for a closed or forged handle. Never traps. lupin 0.1.56 answers the shape rows and refuses a well-formed wait by name, since std has no poll (0.1.55 did not resolve the call, wolf-interp#268).
Capability exec (signal control, with wait_fd; ruling #97 R5); refused at comptime (D33). Delegates to os_signal_wait_fds; a program that names it makes the signal hub and its wake pipe before main. The example is prose, since a handle comes from std.fs: an editor listens for signal.resize(), then loops on signal.wait_fds(watched, signal.resize(), 25)?, redrawing on a meaning, reading the file ready names, and ending an escape sequence when neither came. From wolf 0.2.35 an element may wait for a write instead (WAIT_WRITE, s254).
The narrow form (sc82): it answers the lowest ready file alone, so a loop that serves what it answers starves the files after a busy one unless it rotates the list itself, and it takes no socket. std.poll is the wide form: an owned waiter over files and sockets that answers every ready entry with its facts AND a meaning, over the runtime's readiness set rather than repeated calls to this narrow wait. This call is unchanged.
fn · Source line 317
pub fn poll(set: int) -> int ! {io}
The oldest meaning in set that has arrived, taken; 0 when none has. Never waits ([os.signal.poll]).
fn · Source line 323
pub fn ignore(set: int) -> () ! {unsupported, io}
Every meaning in set does nothing to this process — and to every child it starts ([os.signal.disp]).
fn · Source line 328
pub fn reset(set: int) -> () ! {unsupported, io}
Every meaning in set does what the host does by default.
fn · Source line 369
pub fn ignore_one(meaning: int) -> () ! {invalid, io, unsupported}
**s246 ([os.signal.disp.one], ruling #88 R1): ONE meaning does nothing to this process** — and to every child it starts — named in the SENDING shape: one meaning of the table, any of the twenty-eight but kill() and stop(), or a host number host(n) (a real-time signal is host(realtime()?.first + k)). This is how a program ignores a send-only meaning or a signal the table has no meaning for: GNU timeout -s SEGV and -s RTMIN lead a group, ignore what they are about to send it, send it and live. ignore takes a SET of listenable meanings and is unchanged.
Rows, in the order they are decided: invalid for 0, for anything send refuses (two meanings, a bit no release publishes, a host number past last()), for kill() and stop() by bit or by number, which no process can ignore, and from wolf 0.2.35 for the C library's own numbers (host's doc; 0.2.33 and 0.2.34 answered glibc's refusal of 32 and 33 io); then unsupported on windows; then io where the host refuses the number. Nothing changes on a row. Never traps.
A listenable meaning, by its bit or its number, is the set calls' ([os.signal.disp]): the ignore ends a listen, ignored reads it, and a child inherits it across exec, as for every ignored meaning. segment_fault() and bus_error() stay the runtime's stack guard's: under the ignore a SENT one does nothing, while a real fault is still the runtime's (the stack-overflow report and exit 134). The checked machine refuses those two by name. lupin 0.1.55 answers the shape rows (invalid) and refuses a well-formed call by name, since it has no sigaction (is77, wolf-interp#261).
Capability exec; refused at comptime (D33). Delegates to os_signal_ignore_one.
var row = "ignored"
signal.ignore_one(signal.kill()) else |_| { row = "refused" }
row == "refused"
fn · Source line 396
pub fn reset_one(meaning: int) -> () ! {invalid, io, unsupported}
**s246 ([os.signal.disp.one], ruling #88 R1): ONE meaning does what the host does by default** — the undo of ignore_one, in the same sending shape (one meaning of the table but kill() and stop(), or host(n)). reset takes a SET of listenable meanings and is unchanged. A child started after it gets the default as exec leaves it.
Rows, in ignore_one's order: invalid for 0, anything send refuses, kill() and stop(), and the C library's own numbers (wolf 0.2.35); unsupported on windows; io where the host refuses the number. Never traps. The checked machine refuses segment_fault() and bus_error() by name; lupin 0.1.55 answers the shape rows and refuses a well-formed call by name (is77, wolf-interp#261).
Capability exec; refused at comptime (D33). Delegates to os_signal_default_one.
var row = "reset"
signal.reset_one(signal.terminate() | signal.user()) else |_| { row = "refused" }
row == "refused"
fn · Source line 401
pub fn raise(meaning: int) -> () ! {io}
Send meaning to this process (os_signal_raise).
fn · Source line 431
pub fn send(pid: int, meaning: int) -> () ! {unsupported, invalid, not_found, denied, io}
**s232 ([os.signal.send]): send meaning's signal to the process pid** — kill(2) for one process. meaning is one meaning of the table, a host number (host(n), from wolf 0.2.31: -n was invalid before), or 0, which sends nothing and answers the same rows: "is there such a process, and may I signal it". A process id names whichever process holds it NOW (a child already reaped may have passed its id on); std.process.kill on a Child has no such hazard. A send to this process's own id is a process-directed raise.
Rows, in the order they are decided: invalid when pid is not above 0 or does not fit a process id, or meaning is neither 0, nor exactly one meaning, nor host(n) with 1 <= n <= last() (nothing is sent); unsupported on a host with no such call (windows, by name); then the target's — not_found when no process has that id, denied when this process may not signal it, io otherwise. Never traps. lupin answers the shape and declines the send itself by name (no host call without unsafe).
Capability exec; refused at comptime (D33). Delegates to os_signal_send.
var row = "sent"
signal.send(0, signal.terminate()) else |_| { row = "refused" }
row == "refused"
fn · Source line 460
pub fn send_group(g: process.Group, meaning: int) -> () ! { unsupported, invalid, not_found, denied, io, }
**s241 ([os.signal.send.group], ruling #79 R1): send meaning's signal to every member of the process group g** that this process may signal — kill(-pgid), what kill %1, fg, bg and kill -- -N do to a job. meaning is one meaning of the table, a host number (host(n)), or 0, which sends nothing and asks the group the same question. A STOP stops every member and a continued() continues them; the parent hears each member's stop through std.process.poll. kill 0 is send_group(process.own_group()?, m), and it reaches this process too.
Rows, in the order they are decided: invalid for a group id not above 1 or wider than a process id — group 1 cannot be named, so a miscomputed id never becomes a broadcast (send_all is that, by name) — or a meaning send refuses; unsupported on windows; then the host's answer, kept as it is (ruling #79 R3): not_found for a group with no member, denied when this process may signal none of them, io otherwise. A group some of whose members may be signalled is ok and reaches those only; a group of ended, unreaped members is ok on linux and denied on macOS. Never traps. lupin answers the shape and declines the send itself by name.
Capability exec; refused at comptime (D33). Delegates to os_signal_send_group. The example is prose, since a doc example imports only this module: signal.send_group(process.Group { id: 1 }, signal.terminate()) is invalid.
fn · Source line 492
pub fn send_all(meaning: int) -> () ! {unsupported, invalid, not_found, denied, io}
**s241 ([os.signal.send.all], ruling #79 R1): send meaning's signal to every process this one may signal**, itself excepted — kill(-1), XCU kill -1. Which processes that is is the host's rule: as the super-user every process but this one (and, on linux, its pid namespace's process 1); as another user, that user's processes in any session or group. It has a name of its own so that no miscomputed pid or group becomes it.
Rows: invalid for a meaning send refuses; unsupported on windows; then the host's answer as it is: on linux ok when it found any other process, even only ones it may not signal, and not_found when it found none; denied where a host says so; io otherwise. Never traps. lupin answers the shape and declines the send by name.
Capability exec; refused at comptime (D33). Delegates to os_signal_send_all.
var row = "sent"
signal.send_all(signal.terminate() | signal.user()) else |_| { row = "refused" }
row == "refused"
fn · Source line 516
pub fn number(meaning: int) -> int ! {invalid, unsupported}
**s232 ([os.signal.number]): the number THIS host gives meaning** — what kill -l prints, what trap … 13 names and what a shell's 128 + N decodes. It differs between hosts, which is why nothing else in this module takes or answers one.
Rows: invalid for anything but exactly one meaning of the table; unsupported on a host that does not number signals (windows). Never traps.
Carries no capability (it reads the host's numbering and nothing else), and is refused at comptime all the same: the compiling host's number is not the running one's (D33). Delegates to os_signal_number.
let n = signal.number(signal.interrupt()) else |_| 1
n >= 1
let none = signal.number(0) else |_| 0 - 1
none == 0 - 1
fn · Source line 532
pub fn last() -> int ! {unsupported}
**s241 ([os.signal.host], ruling #79 R4): this host's last signal number** — the C library's SIGRTMAX on linux (64 under glibc and musl), 31 on macOS. A host number N from 1 to this is what host(N) spells and what send, send_group, send_all and text take.
Rows: unsupported on windows (no signal numbers) and on a host wolf has not measured. Never traps. Uncharged (it reads the host's table, as number), and refused at comptime all the same. lupin declines by name (it does not read the C library's range), so the example is prose: signal.last()? is 64 on linux.
Delegates to os_signal_last.
fn · Source line 553
pub fn realtime() -> Realtime ! {unsupported}
**s241 ([os.signal.host]): the real-time range**, as Realtime.
Rows: unsupported on windows and on a host wolf has not measured. Never traps. Uncharged; refused at comptime. lupin declines by name, so the example is prose: signal.realtime()?.first is 34 under glibc.
Delegates to os_signal_realtime.
fn · Source line 585
pub fn text(meaning: int) -> str ! {invalid, unsupported}
**s241 ([os.signal.text], ruling #79 R5): the host C library's words for meaning's signal**, or for host signal N given host(N) — strsignal(3), what GNU kill -t prints and what a shell says of a job a signal ended. Always in the C locale, whatever LANG says. The words are the host's BY DESIGN and differ between C libraries: glibc's kill() is "Killed", macOS's "Killed: 9" (it appends the number to all 28); glibc and musl part on arithmetic() and child() and on every real-time number.
Rows: invalid for any meaning send refuses (two meanings, a bit no release publishes, a host number past last()), before the host; unsupported on windows. 0 answers per version: invalid before the host at wolf 0.2.32; from wolf 0.2.33 (s246, wolf-lang#787) signal 0's words, glibc's "Unknown signal 0" and macOS's "Unknown signal: 0", and unsupported on windows. musl's words for 0 are unmeasured: no release archive targets musl. Never traps. Uncharged; refused at comptime. lupin answers the shape rows (invalid) and refuses a well-formed call by name, 0 included since lupin 0.1.55 (0.1.54 answered 0 invalid; is77, wolf-interp#262): a table there would be one C library's.
Delegates to os_signal_text.
let t = signal.text(signal.terminate() | signal.user()) else |_| "invalid"
t == "invalid"
fn · Source line 619
pub fn host(n: int) -> int
The meaning value that names host signal n ([os.signal.host], ruling #79 R4): -n, os_wait_status's spelling of "ended by signal n", so a program re-sends what it saw. For the signals the table gives no meaning — linux STKFLT, IO, PWR and the real-time range; macOS EMT, IO, INFO — and for a number a user typed (kill -9). It makes NO portability promise: n is this host's number, and for the real-time range this C library's. Only send, send_group, send_all, text, ignore_one, reset_one and std.process.exit_signal take one (the last three from wolf 0.2.33), for 1 <= n <= last(); every set-taking call refuses it (a negative set fails the one shape rule).
The C library's own numbers ([os.signal.host.reserved], wolf 0.2.35's s253; ruling asked R-sc72-2): on linux, from 32 up to and not including realtime()'s first — glibc's 32 and 33, musl's 32 to 34 — are the C library's (its threads' cancellation and set-id signals), and wolf gives them no meaning. ignore_one, reset_one and std.process.exit_signal refuse host(n) of one **invalid**, by name, before the host, on every machine: a disposition the C library owns is not the program's to set, and an end by one was never kept. The sends and text take them as before. macOS has no real-time signals and windows no numbers, so neither has such a number.
Total and pure; nothing is checked until a call takes it — this function keeps its released signature, and the refusal by name is the calls' (tests/signal/reserved_rows.lu).
signal.host(9) == 0 - 9
fn · Source line 636
pub fn ignored() -> int ! {unsupported}
**s232 ([os.signal.ignored]): the set of listenable meanings this process ignores NOW.** It changes nothing. Read before the program's own first ignore, reset or listen, it is what the process was STARTED ignoring — what a shell's trap must leave alone and what makes nohup work. A listened meaning is not ignored.
Rows: unsupported on a host with no dispositions (windows). Never traps. lupin declines by name (no sigaction without unsafe), so the example is prose: signal.ignored()? & signal.reload() != 0 asks whether this program runs under nohup.
Capability env (ruling #70 R8); refused at comptime (D33). Delegates to os_signal_ignored.