rt_sigaction(2)
| Field | Value |
|---|---|
| Numbers (x64 / i386 / arm64-generic / arm32) | rt_sigaction: 13 / 174 / 134 / 174 (ledger SC-rt_sigaction; verified syscall_64.tbl line 25, syscall_generic.tbl line 170, syscall_arm.tbl line 191, syscall_32.tbl line 189); legacy sigaction: - / 67 / - / 67 (ledger SC-sigaction; verified syscall_32.tbl line 82) |
| Since (kernel) | rt_sigaction 2.2 (sigaction.2: “with the addition of real-time signals in Linux 2.2 … rt_sigaction() was added”); legacy sigaction 1.0 (ledger SC-sigaction) |
| Man page | man2/sigaction.2 (cached); rt_sigaction.2 is an .so alias (“.so man2/sigaction.2”) |
| glibc wrapper | glibc sigaction(3) transparently calls rt_sigaction() when the kernel provides it and hides the sigsetsize argument (sigaction.2, C library/kernel differences); returns EINVAL on attempts to change the disposition of the two NPTL-internal real-time signals (sigaction.2) |
| Aliases covered | rt_sigaction (kernel name), legacy sigaction (i386/arm32 slot 67, 32-bit sigset_t ABI) |
| Ledger ID | SC-rt_sigaction, SC-sigaction |
Purpose
rt_sigaction() installs or queries the disposition of one signal: what happens when that signal is delivered (default action, ignore, or a handler). It is the rt_* form of the original sigaction() syscall, added in Linux 2.2 because the fixed-size 32-bit sigset_t of the old call could not express the real-time signal range (sigaction.2, C library/kernel differences).
Synopsis
#include <signal.h>
int sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact);
/* kernel ABI */
int rt_sigaction(int signum, const struct kernel_sigaction *act,
struct kernel_sigaction *oldact, size_t sigsetsize);
Arguments and behavior
signum is the signal number (from <signal.h>; SIGKILL and SIGSTOP cannot be changed). If act is non-NULL the new action is installed; if oldact is non-NULL the previous action is saved; both may be NULL (sigaction.2). The struct sigaction in user space (glibc bits/sigaction.h) holds a handler union (sa_handler, or sa_sigaction with SA_SIGINFO), sa_mask (blocked during handler execution, in addition to the triggering signal unless SA_NODEFER), sa_flags, and sa_restorer (not for application use). The kernel call takes a fourth argument sigsetsize, currently required to equal sizeof(sigset_t) or EINVAL results (sigaction.2).
Return value and errors
0 on success; -1 with errno on error. Errors (sigaction.2): EFAULT (act or oldact points outside the address space); EINVAL (invalid signal, or attempt to change SIGKILL/SIGSTOP, or wrong sigsetsize on the kernel call).
Flags and constants
| Flag | Value (glibc bits/sigaction.h unless noted) | Meaning (sigaction.2) | Since |
|---|---|---|---|
| SA_NOCLDSTOP | 1 | no SIGCHLD when children stop/continue | 1.0 |
| SA_NOCLDWAIT | 2 | do not create zombies on child death | 2.6 (man: 2.5.60 comment) |
| SA_SIGINFO | 4 | three-argument handler (sig, siginfo_t *, ucontext) | 2.2 |
| SA_ONSTACK | 0x08000000 | run handler on sigaltstack(2) stack | 1.0 |
| SA_RESTART | 0x10000000 | BSD-style restartable syscalls | 1.0 |
| SA_NODEFER | 0x40000000 | do not block the signal inside its handler (alias SA_NOMASK) | 1.0 |
| SA_RESETHAND | 0x80000000 | reset to SIG_DFL on handler entry (alias SA_ONESHOT) | 1.0 |
| SA_INTERRUPT | 0x20000000 | historical no-op (glibc __USE_MISC only) | - |
| SA_RESTORER | not exposed in glibc headers | kernel-internal: sa_restorer holds the trampoline (see sigreturn) | - |
| SA_UNSUPPORTED | value unverified (not in installed headers) | probe for flag-bit support | 5.11 |
| SA_EXPOSE_TAGBITS | value unverified (not in installed headers) | keep arch tag bits in si_addr | 5.11 |
Security and notes
Dispositions of handled signals reset to default across execve(); ignored dispositions persist; fork() inherits dispositions (sigaction.2 NOTES). POSIX leaves behavior undefined after ignoring SIGFPE/SIGILL/SIGSEGV not generated by kill(2)/raise(3). Attempts to block SIGKILL/SIGSTOP in sa_mask are silently ignored.
References
- https://man7.org/linux/man-pages/man2/sigaction.2.html
- /usr/include/x86_64-linux-gnu/bits/sigaction.h (struct and flag values)
- worklog Task 1-e (signal-time chapter, kernel 2.2 rt_* split)