signal(7)

๐Ÿ’– NAME ๐Ÿ’–

okay bestie, this is signal(7) from the Miscellaneous Information Manual, and it's literally the overview of signals. Not me showing up with the whole lore, but here we are. ๐Ÿซถ

โœจ DESCRIPTION โœจ

Linux supports both POSIX reliable signals (hereinafter "standard signals") and POSIX real-time signals. No cap. ๐Ÿ’…

๐Ÿฆ‹ Signal dispositions ๐Ÿฆ‹

Each signal has a current disposition, which determines how the process behaves when it is delivered the signal. It's giving "what's your vibe when the signal pulls up?"

The entries in the Action column of the table below specify the default disposition for each signal, as follows:

  • Term โ€” default action is to terminate the process. ๐Ÿ’€
  • Ign โ€” default action is to ignore the signal. ๐Ÿ™ˆ
  • Core โ€” default action is to terminate the process and dump core (see core(5)). ๐Ÿ’ฅ
  • Stop โ€” default action is to stop the process. โœ‹
  • Cont โ€” default action is to continue the process if it is currently stopped. โ–ถ๏ธ

A process can change the disposition of a signal using sigaction(2) or signal(2). (The latter is less portable when establishing a signal handler; see signal(2) for details.) Using these system calls, a process can elect one of the following behaviors to occur on delivery of the signal:

  • perform the default action;
  • ignore the signal; or
  • catch the signal with a signal handler, a programmer-defined function that is automatically invoked when the signal is delivered.

By default, a signal handler is invoked on the normal process stack. It is possible to arrange that the signal handler uses an alternate stack; see sigaltstack(2) for a discussion of how to do this and when it might be useful. Lowkey iconic. ๐Ÿฆ‹

The signal disposition is a per-process attribute: in a multithreaded application, the disposition of a particular signal is the same for all threads. So no "I'm the exception" energy. Periodt.

A child created via fork(2) inherits a copy of its parent's signal dispositions. During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged. That's the tea. ๐Ÿ“

๐Ÿ“ฃ Sending a signal ๐Ÿ“ฃ

The following system calls and library functions allow the caller to send a signal:

  • raise(3) โ€” sends a signal to the calling thread.
  • kill(2) โ€” sends a signal to a specified process, to all members of a specified process group, or to all processes on the system.
  • pidfd_send_signal(2) โ€” sends a signal to a process identified by a PID file descriptor.
  • killpg(3) โ€” sends a signal to all of the members of a specified process group.
  • pthread_kill(3) โ€” sends a signal to a specified POSIX thread in the same process as the caller.
  • tgkill(2) โ€” sends a signal to a specified thread within a specific process. (This is the system call used to implement pthread_kill(3).)
  • sigqueue(3) โ€” sends a real-time signal with accompanying data to a specified process.

โณ Waiting for a signal to be caught โณ

The following system calls suspend execution of the calling thread until a signal is caught (or an unhandled signal terminates the process):

  • pause(2) โ€” suspends execution until any signal is caught.
  • sigsuspend(2) โ€” temporarily changes the signal mask (see below) and suspends execution until one of the unmasked signals is caught.

๐Ÿซถ Synchronously accepting a signal ๐Ÿซถ

Rather than asynchronously catching a signal via a signal handler, it is possible to synchronously accept the signal, that is, to block execution until the signal is delivered, at which point the kernel returns information about the signal to the caller. There are two general ways to do this:

  • sigwaitinfo(2), sigtimedwait(2), and sigwait(3) suspend execution until one of the signals in a specified set is delivered. Each of these calls returns information about the delivered signal.
  • signalfd(2) returns a file descriptor that can be used to read information about signals that are delivered to the caller. Each read(2) from this file descriptor blocks until one of the signals in the set specified in the signalfd(2) call is delivered to the caller. The buffer returned by read(2) contains a structure describing the signal.

๐Ÿง  Signal mask and pending signals ๐Ÿง 

A signal may be blocked, which means that it will not be delivered until it is later unblocked. Between the time when it is generated and when it is delivered a signal is said to be pending. No cap, it's just waiting in the queue.

Each thread in a process has an independent signal mask, which indicates the set of signals that the thread is currently blocking. A thread can manipulate its signal mask using pthread_sigmask(3). In a traditional single-threaded application, sigprocmask(2) can be used to manipulate the signal mask.

A child created via fork(2) inherits a copy of its parent's signal mask; the signal mask is preserved across execve(2).

A signal may be process-directed or thread-directed. A process-directed signal is one that is targeted at (and thus pending for) the process as a whole. A signal may be process-directed because it was generated by the kernel for reasons other than a hardware exception, or because it was sent using kill(2) or sigqueue(3). A thread-directed signal is one that is targeted at a specific thread. A signal may be thread-directed because it was generated as a consequence of executing a specific machine-language instruction that triggered a hardware exception (e.g., SIGSEGV for an invalid memory access, or SIGFPE for a math error), or because it was targeted at a specific thread using interfaces such as tgkill(2) or pthread_kill(3).

A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.

A thread can obtain the set of signals that it currently has pending using sigpending(2). This set will consist of the union of the set of pending process-directed signals and the set of signals pending for the calling thread.

A child created via fork(2) initially has an empty pending signal set; the pending signal set is preserved across an execve(2).

๐Ÿš€ Execution of signal handlers ๐Ÿš€

Whenever there is a transition from kernel-mode to user-mode execution (e.g., on return from a system call or scheduling of a thread onto the CPU), the kernel checks whether there is a pending unblocked signal for which the process has established a signal handler. If there is such a pending signal, the following steps occur:

  1. (1) The kernel performs the necessary preparatory steps for execution of the signal handler:
    • (1.1) The signal is removed from the set of pending signals.
    • (1.2) If the signal handler was installed by a call to sigaction(2) that specified the SA_ONSTACK flag and the thread has defined an alternate signal stack (using sigaltstack(2)), then that stack is installed.
    • (1.3) Various pieces of signal-related context are saved into a special frame that is created on the stack. The saved information includes:
      • the program counter register (i.e., the address of the next instruction in the main program that should be executed when the signal handler returns);
      • architecture-specific register state required for resuming the interrupted program;
      • the thread's current signal mask;
      • the thread's alternate signal stack settings.

If the signal handler was installed using the sigaction(2) SA_SIGINFO flag, then the above information is accessible via the ucontext_t object that is pointed to by the third argument of the signal handler. This object reflects the state at which the signal is delivered, rather than in the handler; for example, the mask of blocked signals stored in this object will not contain the mask of new signals blocked through sigaction(2).

  • (1.4) Any signals specified in act->sa_mask when registering the handler with sigaction(2) are added to the thread's signal mask. The signal being delivered is also added to the signal mask, unless SA_NODEFER was specified when registering the handler. These signals are thus blocked while the handler executes.
  1. (2) The kernel constructs a frame for the signal handler on the stack. The kernel sets the program counter for the thread to point to the first instruction of the signal handler function, and configures the return address for that function to point to a piece of user-space code known as the signal trampoline (described in sigreturn(2)).
  2. (3) The kernel passes control back to user-space, where execution commences at the start of the signal handler function.
  3. (4) When the signal handler returns, control passes to the signal trampoline code.
  4. (5) The signal trampoline calls sigreturn(2), a system call that uses the information in the stack frame created in step 1 to restore the thread to its state before the signal handler was called. The thread's signal mask and alternate signal stack settings are restored as part of this procedure. Upon completion of the call to sigreturn(2), the kernel transfers control back to user space, and the thread recommences execution at the point where it was interrupted by the signal handler.

Note that if the signal handler does not return (e.g., control is transferred out of the handler using siglongjmp(3), or the handler executes a new program with execve(2)), then the final step is not performed. In particular, in such scenarios it is the programmer's responsibility to restore the state of the signal mask (using sigprocmask(2)), if it is desired to unblock the signals that were blocked on entry to the signal handler. (Note that siglongjmp(3) may or may not restore the signal mask, depending on the savesigs value that was specified in the corresponding call to sigsetjmp(3).)

From the kernel's point of view, execution of the signal handler code is exactly the same as the execution of any other user-space code. That is to say, the kernel does not record any special state information indicating that the thread is currently executing inside a signal handler. All necessary state information is maintained in user-space registers and the user-space stack. The depth to which nested signal handlers may be invoked is thus limited only by the user-space stack (and sensible software design!). ๐Ÿ’…

๐Ÿ“Ÿ Standard signals (the OGs) ๐Ÿ’–

okay bestie so Linux supports all the standard signals below, and the second column tells you which standard (if any) was like, "yeah that one's mine":

  • P1990 = the signal was already described in the OG POSIX.1-1990 standard.
  • P2001 = it got added, or its definition got reworked, in SUSv2 and POSIX.1-2001.
  • P2024 = same deal but for POSIX.1-2024.

and the columns are: Signal ยท Standard ยท Action ยท Comment, so here's the whole lineup, no skips, no gaps:

  • SIGABRT โ€” P1990 ยท Core ยท Abort signal from abort(3)
  • SIGALRM โ€” P1990 ยท Term ยท Timer signal from alarm(2)
  • SIGBUS โ€” P2001 ยท Core ยท Bus error (bad memory access)
  • SIGCHLD โ€” P2001 ยท Ign ยท Child stopped, terminated, or continued
  • SIGCLD โ€” - ยท Ign ยท a synonym for SIGCHLD
  • SIGCONT โ€” P1990 ยท Cont ยท Continue if stopped
  • SIGEMT โ€” - ยท Term ยท Emulator trap
  • SIGFPE โ€” P1990 ยท Core ยท Erroneous arithmetic operation
  • SIGHUP โ€” P1990 ยท Term ยท Hangup detected on controlling terminal or death of controlling process
  • SIGILL โ€” P1990 ยท Core ยท Illegal Instruction
  • SIGINFO โ€” - ยท (no action listed) ยท a synonym for SIGPWR
  • SIGINT โ€” P1990 ยท Term ยท Interrupt from keyboard
  • SIGIO โ€” - ยท Term ยท I/O now possible (4.2BSD)
  • SIGIOT โ€” - ยท Core ยท IOT trap. A synonym for SIGABRT
  • SIGKILL โ€” P1990 ยท Term ยท Kill signal
  • SIGLOST โ€” - ยท Term ยท File lock lost (unused)
  • SIGPIPE โ€” P1990 ยท Term ยท Broken pipe: write to pipe with no readers; see pipe(7)
  • SIGPOLL โ€” P2001 ยท Term ยท Pollable event (Sys V); synonym for SIGIO
  • SIGPROF โ€” P2001 ยท Term ยท Profiling timer expired
  • SIGPWR โ€” - ยท Term ยท Power failure (System V)
  • SIGQUIT โ€” P1990 ยท Core ยท Quit from keyboard
  • SIGSEGV โ€” P1990 ยท Core ยท Invalid memory reference
  • SIGSTKFLT โ€” - ยท Term ยท Stack fault on coprocessor (unused)
  • SIGSTOP โ€” P1990 ยท Stop ยท Stop process
  • SIGTSTP โ€” P1990 ยท Stop ยท Stop typed at terminal
  • SIGSYS โ€” P2001 ยท Core ยท Bad system call (SVr4); see also seccomp(2)
  • SIGTERM โ€” P1990 ยท Term ยท Termination signal
  • SIGTRAP โ€” P2001 ยท Core ยท Trace/breakpoint trap
  • SIGTTIN โ€” P1990 ยท Stop ยท Terminal input for background process
  • SIGTTOU โ€” P1990 ยท Stop ยท Terminal output for background process
  • SIGUNUSED โ€” - ยท Core ยท Synonymous with SIGSYS
  • SIGURG โ€” P2001 ยท Ign ยท Urgent condition on socket (4.2BSD)
  • SIGUSR1 โ€” P1990 ยท Term ยท User-defined signal 1
  • SIGUSR2 โ€” P1990 ยท Term ยท User-defined signal 2
  • SIGVTALRM โ€” P2001 ยท Term ยท Virtual alarm clock (4.2BSD)
  • SIGXCPU โ€” P2001 ยท Core ยท CPU time limit exceeded (4.2BSD); see setrlimit(2)
  • SIGXFSZ โ€” P2001 ยท Core ยท File size limit exceeded (4.2BSD); see setrlimit(2)
  • SIGWINCH โ€” P2024 ยท Ign ยท Window resize signal (4.3BSD, Sun)
๐Ÿšจ bestie listen: SIGKILL and SIGSTOP cannot be caught, blocked, or ignored. They are the ungovernable ones. You cannot negotiate with them. Periodt.

okay now the lore โœจ

Up to and including Linux 2.2, the default behavior for SIGSYS, SIGXCPU, SIGXFSZ, and (on architectures other than SPARC and MIPS) SIGBUS was to terminate the process โ€” and that's terminate without a core dump, btw. (also, on some other UNIX systems the default action for SIGXCPU and SIGXFSZ is to terminate the process without a core dump too.) Linux 2.4 said "no, we're doing it properly" and conforms to the POSIX.1-2001 requirements for these signals, terminating the process with a core dump. glow-up ๐Ÿ’…

SIGEMT is not specified in POSIX.1-2001, but it still shows up on most other UNIX systems, where its default action is typically to terminate the process with a core dump. it's giving "not in the group chat but still at the party".

SIGPWR (which is not specified in POSIX.1-2001) is typically ignored by default on those other UNIX systems where it appears.

SIGIO (which is not specified in POSIX.1-2001) is ignored by default on several other UNIX systems.


๐ŸŒ€ Queueing and delivery semantics for standard signals ๐ŸŒ€

If multiple standard signals are pending for a process, the order in which the signals are delivered is unspecified. no promises, bestie ๐Ÿ˜ญ

Standard signals do not queue. If multiple instances of a standard signal are generated while that signal is blocked, then only one instance of the signal is marked as pending (and the signal will be delivered just once when it is unblocked). And in the case where a standard signal is already pending, the siginfo_t structure (see sigaction(2)) associated with that signal is not overwritten on arrival of subsequent instances of the same signal. So the process will receive the information associated with the first instance of the signal. first come, first served, no takebacks.


๐Ÿ”ข Signal numbering for standard signals ๐Ÿ”ข

The numeric value for each signal is right here below. And as the table shows, many signals have different numeric values on different architectures โ€” iconic chaotic behavior honestly. Here's how to read it:

  • the first numeric value in each row = the signal number on x86, ARM, and most other architectures
  • the second value = for Alpha and SPARC
  • the third = for MIPS
  • the last = for PARISC
  • and a dash (-) means that signal is absent on the corresponding architecture.
  • SIGHUP โ€” x86/ARM & most others 1; Alpha/SPARC 1; MIPS 1; PARISC 1
  • SIGINT โ€” x86/ARM & most others 2; Alpha/SPARC 2; MIPS 2; PARISC 2
  • SIGQUIT โ€” x86/ARM & most others 3; Alpha/SPARC 3; MIPS 3; PARISC 3
  • SIGILL โ€” x86/ARM & most others 4; Alpha/SPARC 4; MIPS 4; PARISC 4
  • SIGTRAP โ€” x86/ARM & most others 5; Alpha/SPARC 5; MIPS 5; PARISC 5
  • SIGABRT โ€” x86/ARM & most others 6; Alpha/SPARC 6; MIPS 6; PARISC 6
  • SIGIOT โ€” x86/ARM & most others 6; Alpha/SPARC 6; MIPS 6; PARISC 6
  • SIGBUS โ€” x86/ARM & most others 7; Alpha/SPARC 10; MIPS 10; PARISC 10
  • SIGEMT โ€” x86/ARM & most others -; Alpha/SPARC 7; MIPS 7; PARISC -
  • SIGFPE โ€” x86/ARM & most others 8; Alpha/SPARC 8; MIPS 8; PARISC 8
  • SIGKILL โ€” x86/ARM & most others 9; Alpha/SPARC 9; MIPS 9; PARISC 9
  • SIGUSR1 โ€” x86/ARM & most others 10; Alpha/SPARC 30; MIPS 16; PARISC 16
  • SIGSEGV โ€” x86/ARM & most others 11; Alpha/SPARC 11; MIPS 11; PARISC 11
  • SIGUSR2 โ€” x86/ARM & most others 12; Alpha/SPARC 31; MIPS 17; PARISC 17
  • SIGPIPE โ€” x86/ARM & most others 13; Alpha/SPARC 13; MIPS 13; PARISC 13
  • SIGALRM โ€” x86/ARM & most others 14; Alpha/SPARC 14; MIPS 14; PARISC 14
  • SIGTERM โ€” x86/ARM & most others 15; Alpha/SPARC 15; MIPS 15; PARISC 15
  • SIGSTKFLT โ€” x86/ARM & most others 16; Alpha/SPARC -; MIPS -; PARISC 7
  • SIGCHLD โ€” x86/ARM & most others 17; Alpha/SPARC 20; MIPS 18; PARISC 18
  • SIGCLD โ€” x86/ARM & most others -; Alpha/SPARC -; MIPS 18; PARISC -
  • SIGCONT โ€” x86/ARM & most others 18; Alpha/SPARC 19; MIPS 25; PARISC 26
  • SIGSTOP โ€” x86/ARM & most others 19; Alpha/SPARC 17; MIPS 23; PARISC 24
  • SIGTSTP โ€” x86/ARM & most others 20; Alpha/SPARC 18; MIPS 24; PARISC 25
  • SIGTTIN โ€” x86/ARM & most others 21; Alpha/SPARC 21; MIPS 26; PARISC 27
  • SIGTTOU โ€” x86/ARM & most others 22; Alpha/SPARC 22; MIPS 27; PARISC 28
  • SIGURG โ€” x86/ARM & most others 23; Alpha/SPARC 16; MIPS 21; PARISC 29
  • SIGXCPU โ€” x86/ARM & most others 24; Alpha/SPARC 24; MIPS 30; PARISC 12
  • SIGXFSZ โ€” x86/ARM & most others 25; Alpha/SPARC 25; MIPS 31; PARISC 30
  • SIGVTALRM โ€” x86/ARM & most others 26; Alpha/SPARC 26; MIPS 28; PARISC 20
  • SIGPROF โ€” x86/ARM & most others 27; Alpha/SPARC 27; MIPS 29; PARISC 21
  • SIGWINCH โ€” x86/ARM & most others 28; Alpha/SPARC 28; MIPS 20; PARISC 23
  • SIGIO โ€” x86/ARM & most others 29; Alpha/SPARC 23; MIPS 22; PARISC 22
  • SIGPOLL โ€” Notes: same as SIGIO
  • SIGPWR โ€” x86/ARM & most others 30; Alpha/SPARC 29/-; MIPS 19; PARISC 19
  • SIGINFO โ€” x86/ARM & most others -; Alpha/SPARC 29/-; MIPS -; PARISC -
  • SIGLOST โ€” x86/ARM & most others -; Alpha/SPARC -/29; MIPS -; PARISC -
  • SIGSYS โ€” x86/ARM & most others 31; Alpha/SPARC 12; MIPS 12; PARISC 31
  • SIGUNUSED โ€” x86/ARM & most others 31; Alpha/SPARC -; MIPS -; PARISC 31

Note the following, bestie:

  • Where defined, SIGUNUSED is synonymous with SIGSYS. Since glibc 2.26, SIGUNUSED is no longer defined on any architecture. it's gone. retired. living its best life off the grid ๐Ÿฆ‹
  • Signal 29 is SIGINFO/SIGPWR (synonyms for the same value) on Alpha but SIGLOST on SPARC. same number, different personalities ๐Ÿ˜ญ

๐ŸŒธ Real-time signals ๐ŸŒธ

Starting with Linux 2.2, Linux supports real-time signals as originally defined in the POSIX.1b real-time extensions (and now included in POSIX.1-2001). The range of supported real-time signals is defined by the macros SIGRTMIN and SIGRTMAX. And POSIX.1-2001 requires that an implementation support at least _POSIX_RTSIG_MAX (8) real-time signals โ€” so, bare minimum, eight.

The Linux kernel supports a range of 33 different real-time signals, numbered 32 to 64. But โ€” plot twist โ€” the glibc POSIX threads implementation internally uses two (for NPTL) or three (for LinuxThreads) real-time signals (see pthreads(7)), and adjusts the value of SIGRTMIN suitably (to 34 or 35). And because the range of available real-time signals varies according to the glibc threading implementation (and this variation can occur at run time according to the available kernel and glibc), and indeed the range of real-time signals varies across UNIX systems, programs should never refer to real-time signals using hard-coded numbers. Instead they should always refer to real-time signals using the notation SIGRTMIN+n, and include suitable (run-time) checks that SIGRTMIN+n does not exceed SIGRTMAX. do not hardcode. I am begging you. ๐Ÿ™

Unlike standard signals, real-time signals have no predefined meanings: the entire set of real-time signals can be used for application-defined purposes. blank canvas energy โœจ

The default action for an unhandled real-time signal is to terminate the receiving process.

Real-time signals are distinguished by the following, and this is the good part:

  • Multiple instances of real-time signals can be queued. By contrast, if multiple instances of a standard signal are delivered while that signal is currently blocked, then only one instance is queued. (standard signals could never ๐Ÿ˜”)
  • If the signal is sent using sigqueue(3), an accompanying value (either an integer or a pointer) can be sent with the signal. If the receiving process establishes a handler for this signal using the SA_SIGINFO flag to sigaction(2), then it can obtain this data via the si_value field of the siginfo_t structure passed as the second argument to the handler. Furthermore, the si_pid and si_uid fields of this structure can be used to obtain the PID and real user ID of the process sending the signal. so you get the who AND the what, obsessed.
  • Real-time signals are delivered in a guaranteed order. Multiple real-time signals of the same type are delivered in the order they were sent. If different real-time signals are sent to a process, they are delivered starting with the lowest-numbered signal. (I.e., low-numbered signals have highest priority.) By contrast, if multiple standard signals are pending for a process, the order in which they are delivered is unspecified. real-time said "I have a system", standard said "we'll see" ๐Ÿ’€

If both standard and real-time signals are pending for a process, POSIX leaves it unspecified which is delivered first. Linux, like many other implementations, gives priority to standard signals in this case.

Okay so POSIX says an implementation should let you queue at least _POSIX_SIGQUEUE_MAX (that's 32) real-time signals to a process. Cute! But Linux said "not me being different" ๐Ÿ™ˆ Up to and including Linux 2.6.7, Linux put a system-wide limit on how many queued real-time signals all processes could have together. You can peek at that limit in /proc/sys/kernel/rtsig-max, and (if you've got privilege) change it too. Its little sibling /proc/sys/kernel/rtsig-nr tells you how many real-time signals are queued right now. Then in Linux 2.6.8 those /proc interfaces got replaced by the RLIMIT_SIGPENDING resource limit, which is a per-user cap on queued signals. More deets in setrlimit(2). โœจ


Real-time signals showing up meant the signal set structure (sigset_t) had to go from 32 to 64 bits, bestie โ€” glow up fr. And that meant a whole bunch of system calls got superseded by new ones that could handle the bigger sets. The old-to-new lineup:

๐Ÿ›‘ Interruption of system calls and library functions by signal handlers ๐Ÿ›‘

So picture this: a signal handler pops off while a system call or library function call is blocked. Two possible endings, and you don't get to pick by vibes:

  • the call gets automatically restarted once the signal handler returns; or
  • the call fails with the error EINTR.

Which one happens depends on the interface and on whether the signal handler was set up with the SA_RESTART flag (go see sigaction(2)). The deets differ across UNIX systems โ€” below is the Linux tea. ๐Ÿซ–

If a blocked call to one of these interfaces gets interrupted by a signal handler, then it gets automatically restarted after the handler returns if SA_RESTART was used; otherwise the call fails with the error EINTR:

But these next ones? Never restarted. Periodt. Regardless of SA_RESTART, they always fail with the error EINTR when a signal handler interrupts them:

And sleep(3)? Also never restarted if a handler interrupts it, BUT it comes back with a success return: the number of seconds remaining to sleep. no cap, it's built different โœจ

Oh and in certain circumstances the seccomp(2) user-space notification feature can cause system calls to get restarted that would otherwise never be restarted by SA_RESTART โ€” the lore is in seccomp_unotify(2).

โœ‹ Interruption of system calls and library functions by stop signals โœ‹

On Linux, even when there are no signal handlers at all, some blocking interfaces can fail with the error EINTR after the process gets stopped by one of the stop signals and then resumed via SIGCONT. POSIX.1 does not sanction this behavior, and it doesn't happen on other systems. Linux just doing its own thing, as always ๐Ÿ˜ญ

The Linux interfaces serving this look:


๐Ÿ“œ STANDARDS ๐Ÿ“œ

POSIX.1, except as noted. Yep, that's the whole vibe โ€” except as noted, and bestie there were SO many notes.


๐Ÿ“ NOTES ๐Ÿ“

Wanna get into async-signal-safe functions? That's a whole other conversation โ€” see signal-safety(7). ๐Ÿงš

The /proc/pid/task/tid/status file has a bunch of fields showing what signals a thread is blocking (SigBlk), catching (SigCgt), or ignoring (SigIgn). (Fun fact: the set of signals that are caught or ignored will be the same across all threads in a process.) Other fields show the set of pending signals directed at the thread (SigPnd) plus the set of pending signals directed at the process as a whole (ShdPnd). The matching fields over in /proc/pid/status show this info for the main thread. More in proc(5). ๐ŸŒธ


๐Ÿ’€ BUGS ๐Ÿ’€

There are six signals that can be delivered as a consequence of a hardware exception: SIGBUS, SIGEMT, SIGFPE, SIGILL, SIGSEGV, and SIGTRAP. Which one gets delivered for any given hardware exception is not documented and does not always make sense. ๐Ÿ™ƒ

Example: an invalid memory access that causes delivery of SIGSEGV on one CPU architecture might cause delivery of SIGBUS on another architecture, or vice versa.

Another example: using the x86 int instruction with a forbidden argument (any number other than 3 or 128) causes delivery of SIGSEGV, even though SIGILL would make more sense โ€” because of how the CPU reports the forbidden operation to the kernel. The hardware said "trust me" and we simply did not ๐Ÿ˜ญ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

kill(1), clone(2), getrlimit(2), kill(2), pidfd_send_signal(2), restart_syscall(2), rt_sigqueueinfo(2), setitimer(2), setrlimit(2), sgetmask(2), sigaction(2), sigaltstack(2), signal(2), signalfd(2), sigpending(2), sigprocmask(2), sigreturn(2), sigsuspend(2), sigwaitinfo(2), abort(3), bsd_signal(3), killpg(3), longjmp(3), pthread_sigqueue(3), raise(3), sigqueue(3), sigset(3), sigsetops(3), sigvec(3), sigwait(3), strsignal(3), swapcontext(3), sysv_signal(3), core(5), proc(5), nptl(7), pthreads(7), sigevent(3type) โ€” the whole friend group, basically ๐Ÿซถ


and that's a wrap on signal(7), bestie! ๐ŸŽ€ This one's from Linux man-pages 6.20, dated 2026-02-08 โ€” so when you cite it in your assignment, that's the version and the date, no cap ๐Ÿ’– mwah, go forth and catch those signals ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms