Module sys/signals
POSIX signal numbers, as plain integers for std/sys/signal's
on_signal / off_signal / kill.
Signal numbers are NOT uniform across Unix. Numbers 1-15 agree between
Linux and macOS except for three, and everything above 15 was renumbered
wholesale by 4.4BSD, so a portable table has to branch per platform. Four
members here do (SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, via cond on
process.platform); four more differ on macOS and do NOT branch, and are
therefore wrong there — see the warnings on SIGBUS, SIGURG, SIGUSR1
and SIGUSR2, and issues/sys-signals-macos-numbers-are-linux-values.md.
Non-Unix targets take the Linux arm.
std/signal.yo is the portable surface — its Signal enum carries its own
per-platform number table (_signal_num) with the macOS values right, and
deliberately does not read this module.
Stability
unstable — and not merely by convention: the table is known to be wrong on
macOS for four of its 27 entries, so freezing it would freeze a bug. It is
also a raw numeric table with one Yo consumer, the std/sys/signal tests;
the supported surface is std/signal.yo's Signal enum, which is where a
new signal should be added. Freezing follows fixing the four values and
deciding whether this module should exist at all rather than being folded
into std/signal.yo's table.
Constants
Hangup — the controlling terminal closed, or the session leader exited. Conventionally also "reload your configuration" for a daemon.
Value: 1
Interrupt from the keyboard (Ctrl-C).
Value: 2
Quit from the keyboard (Ctrl-\) — like SIGINT, but the default action
also dumps core.
Value: 3
Illegal instruction.
Value: 4
Trace/breakpoint trap — what a debugger's breakpoints raise.
Value: 5
Abort — what C's abort() raises, and so what a Yo panic ends up as.
This is process termination, and has nothing to do with the unwind
keyword (see AGENTS.md).
Value: 6
Bus error — an unaligned or otherwise unmappable access.
WRONG ON macOS. 7 is Linux's number; macOS's SIGBUS is 10 and its 7
is SIGEMT. This constant does not branch on platform, so on macOS it
names the wrong signal
(issues/sys-signals-macos-numbers-are-linux-values.md).
Value: 7
Arithmetic exception — integer divide by zero, not floating point despite the name (IEEE arithmetic does not trap by default).
Value: 8
Kill. Cannot be caught, blocked or ignored, so on_signal for it is
pointless; kill(pid, SIGKILL) is the unconditional stop.
Value: 9
User-defined signal 1.
WRONG ON macOS. 10 is Linux's number; macOS's SIGUSR1 is 30, and 10
there is SIGBUS — so sending this on macOS crashes the target instead of
poking it (issues/sys-signals-macos-numbers-are-linux-values.md).
std/signal.yo's Signal.User1 has the right value.
Value: 10
Segmentation fault. A -O0 Yo binary that takes this on deep recursion is
out of stack, not corrupting the heap — see the YO_MAIN_STACK_MB note in
AGENTS.md before reaching for a sanitizer.
Value: 11
User-defined signal 2.
WRONG ON macOS. 12 is Linux's number; macOS's SIGUSR2 is 31, and 12
there is SIGSYS, whose default action kills the process
(issues/sys-signals-macos-numbers-are-linux-values.md). std/signal.yo's
Signal.User2 has the right value.
Value: 12
Wrote to a pipe or socket with no reader. Terminates the process by
default, which is why servers normally ignore it and read the EPIPE from
the write instead.
Value: 13
Timer expired (alarm()/setitimer() real time).
Value: 14
Polite termination request — the default of kill(1), and the one a
process is expected to catch in order to shut down cleanly.
Value: 15
A child process stopped or exited. macOS 20, Linux 17.
Value: 17
Continue a stopped process. macOS 19, Linux 18.
Value: 18
Stop the process; like SIGKILL it cannot be caught or ignored.
macOS 17, Linux 19.
Value: 19
Stop typed at the terminal (Ctrl-Z) — catchable, unlike SIGSTOP.
macOS 18, Linux 20.
Value: 20
A background process tried to read from the terminal.
Value: 21
A background process tried to write to the terminal (only when the tty has
TOSTOP set).
Value: 22
Urgent (out-of-band) data arrived on a socket.
WRONG ON macOS. 23 is Linux's number; macOS's SIGURG is 16 and its 23
is SIGIO (issues/sys-signals-macos-numbers-are-linux-values.md).
Value: 23
CPU time limit exceeded (RLIMIT_CPU).
Value: 24
File size limit exceeded (RLIMIT_FSIZE).
Value: 25
Virtual (process CPU time) timer expired.
Value: 26
Profiling timer expired.
Value: 27
The terminal window was resized — the cue to re-read the size from
std/term.
Value: 28