sigaction(2)
๐ sigaction(2) ๐ โ System Calls Manual
๐ธ NAME ๐ธ
sigaction, rt_sigaction โ examine and change a signal action. Periodt.
๐ LIBRARY ๐
Standard C library (libc, -lc).
โจ SYNOPSIS โจ
#include <signal.h>
int sigaction(int signum,
const struct sigaction *_Nullable restrict act,
struct sigaction *_Nullable restrict oldact);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
glibc girlies, listen up:
sigaction():_POSIX_C_SOURCE
siginfo_t:_POSIX_C_SOURCE >= 199309L
๐ DESCRIPTION ๐
Okay so sigaction() is the system call you use to change the action taken by a process on receipt of a specific signal. (Need the whole signals overview? Run don't walk to signal(7), bestie.)
signum specifies the signal and can be any valid signal except SIGKILL and SIGSTOP. Those two are simply not on the menu here.
If act is non-NULL, the new action for signal signum is installed from act. If oldact is non-NULL, the previous action is saved in oldact.
The sigaction structure is defined as something like:
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
On some architectures a union is involved: do not assign to both sa_handler and sa_sigaction. That's the vibe check, fr fr.
The sa_restorer field is not intended for application use. (POSIX does not specify a sa_restorer field.) Some further details of the purpose of this field can be found in sigreturn(2).
sa_handler specifies the action to be associated with signum and can be one of the following:
SIG_DFLfor the default action.SIG_IGNto ignore this signal.- A pointer to a signal handling function. This function receives the signal number as its only argument.
If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead of sa_handler) specifies the signal-handling function for signum. This function receives three arguments, as described below.
sa_mask specifies a mask of signals which should be blocked (i.e., added to the signal mask of the thread in which the signal handler is invoked) during execution of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the SA_NODEFER flag is used.
sa_flags specifies a set of flags which modify the behavior of the signal. It is formed by the bitwise OR of zero or more of the following:
SA_NOCLDSTOPโ IfsignumisSIGCHLD, do not receive notification when child processes stop (i.e., when they receive one ofSIGSTOP,SIGTSTP,SIGTTIN, orSIGTTOU) or resume (i.e., they receiveSIGCONT) (seewait(2)). This flag is meaningful only when establishing a handler forSIGCHLD.SA_NOCLDWAIT(since Linux 2.6) โ IfsignumisSIGCHLD, do not transform children into zombies when they terminate. See alsowaitpid(2). This flag is meaningful only when establishing a handler forSIGCHLD, or when setting that signal's disposition toSIG_DFL.
If the SA_NOCLDWAIT flag is set when establishing a handler for SIGCHLD, POSIX.1 leaves it unspecified whether a SIGCHLD signal is generated when a child process terminates. On Linux, a SIGCHLD signal is generated in this case; on some other implementations, it is not.
SA_NODEFERโ Do not add the signal to the thread's signal mask while the handler is executing, unless the signal is specified inact.sa_mask. Consequently, a further instance of the signal may be delivered to the thread while it is executing the handler. This flag is meaningful only when establishing a signal handler.
SA_NOMASK is an obsolete, nonstandard synonym for this flag.
SA_ONSTACKโ Call the signal handler on an alternate signal stack provided bysigaltstack(2). If an alternate stack is not available, the default stack will be used. This flag is meaningful only when establishing a signal handler.SA_RESETHANDโ Restore the signal action to the default upon entry to the signal handler. This flag is meaningful only when establishing a signal handler.
SA_ONESHOT is an obsolete, nonstandard synonym for this flag.
SA_RESTARTโ Provide behavior compatible with BSD signal semantics by making certain system calls restartable across signals. This flag is meaningful only when establishing a signal handler. Seesignal(7)for a discussion of system call restarting.SA_RESTORERโ Not intended for application use. This flag is used by C libraries to indicate that thesa_restorerfield contains the address of a "signal trampoline". Seesigreturn(2)for more details.SA_SIGINFO(since Linux 2.2) โ The signal handler takes three arguments, not one. In this case,sa_sigactionshould be set instead ofsa_handler. This flag is meaningful only when establishing a signal handler.SA_UNSUPPORTED(since Linux 5.11) โ Used to dynamically probe for flag bit support.
If an attempt to register a handler succeeds with this flag set in act->sa_flags alongside other flags that are potentially unsupported by the kernel, and an immediately subsequent sigaction() call specifying the same signal number and with a non-NULL oldact argument yields SA_UNSUPPORTED clear in oldact->sa_flags, then oldact->sa_flags may be used as a bitmask describing which of the potentially unsupported flags are, in fact, supported. See the section "Dynamically probing for flag bit support" below for more details.
SA_EXPOSE_TAGBITS(since Linux 5.11) โ Normally, when delivering a signal, an architecture-specific set of tag bits are cleared from thesi_addrfield ofsiginfo_t. If this flag is set, an architecture-specific subset of the tag bits will be preserved insi_addr.
Programs that need to be compatible with Linux versions older than 5.11 must use SA_UNSUPPORTED to probe for support.
๐งฌ The siginfo_t argument to a SA_SIGINFO handler ๐งฌ
When the SA_SIGINFO flag is specified in act.sa_flags, the signal handler address is passed via the act.sa_sigaction field. This handler takes three arguments, as follows:
void
handler(int sig, siginfo_t *info, void *ucontext)
{
...
}
These three arguments are as follows
sig โ The number of the signal that caused invocation of the handler.
info โ A pointer to a siginfo_t, which is a structure containing further information about the signal, as described below.
ucontext โ This is a pointer to a ucontext_t structure, cast to void *. The structure pointed to by this field contains signal context information that was saved on the user-space stack by the kernel; for details, see sigreturn(2). Further information about the ucontext_t structure can be found in getcontext(3) and signal(7). Commonly, the handler function doesn't make any use of the third argument.
The siginfo_t data type is a structure with the following fields:
siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
union sigval si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void *si_ptr; /* POSIX.1b signal */
int si_overrun; /* Timer overrun count;
POSIX.1b timers */
int si_timerid; /* Timer ID; POSIX.1b timers */
void *si_addr; /* Memory location which caused fault */
long si_band; /* Band event (was int in
glibc 2.3.2 and earlier) */
int si_fd; /* File descriptor */
short si_addr_lsb; /* Least significant bit of address
(since Linux 2.6.32) */
void *si_lower; /* Lower bound when address violation
occurred (since Linux 3.19) */
void *si_upper; /* Upper bound when address violation
occurred (since Linux 3.19) */
int si_pkey; /* Protection key on PTE that caused
fault (since Linux 4.6) */
void *si_call_addr; /* Address of system call instruction
(since Linux 3.5) */
int si_syscall; /* Number of attempted system call
(since Linux 3.5) */
unsigned int si_arch; /* Architecture of attempted system call
(since Linux 3.5) */
}
si_signo, si_errno and si_code are defined for all signals. (si_errno is generally unused on Linux.) The rest of the struct may be a union, so that one should read only the fields that are meaningful for the given signal:
- Signals sent with
kill(2)andsigqueue(3)fill insi_pidandsi_uid. In addition, signals sent withsigqueue(3)fill insi_intandsi_ptrwith the values specified by the sender of the signal; seesigqueue(3)for more details. - Signals sent by POSIX.1b timers (since Linux 2.6) fill in
si_overrunandsi_timerid. Thesi_timeridfield is an internal ID used by the kernel to identify the timer; it is not the same as the timer ID returned bytimer_create(2). Thesi_overrunfield is the timer overrun count; this is the same information as is obtained by a call totimer_getoverrun(2). These fields are nonstandard Linux extensions. - Signals sent for message queue notification (see the description of
SIGEV_SIGNALinmq_notify(3)) fill insi_int/si_ptr, with thesigev_valuesupplied tomq_notify(3);si_pid, with the process ID of the message sender; andsi_uid, with the real user ID of the message sender. SIGCHLDfills insi_pid,si_uid,si_status,si_utime, andsi_stime, so you get the full tea โ on the child. Here's the breakdown bestie:si_pidis the child's process ID, andsi_uidis the child's real user ID.si_statusholds the child's exit status (ifsi_codeisCLD_EXITED) or the signal number that made the process change state. Andsi_utime/si_stimehold the user and system CPU time the child used โ but heads up, these fields do not include the times used by waited-for children (unlikegetrusage(2)andtimes(2)). Up to Linux 2.6, and since Linux 2.6.27, these fields report CPU time in units ofsysconf(_SC_CLK_TCK). In Linux 2.6 kernels before Linux 2.6.27, a bug meant these fields reported time in units of the (configurable) system jiffy โ seetime(7).SIGILL,SIGFPE,SIGSEGV,SIGBUS, andSIGTRAPfill insi_addrwith the address of the fault. On some architectures, these signals also fill in thesi_trapnofield. โจ
Some suberrors of SIGBUS, in particular BUS_MCEERR_AO and BUS_MCEERR_AR, also fill in si_addr_lsb. That field says the least significant bit of the reported address, and therefore how far the corruption spreads. For example, if a full page was corrupted, si_addr_lsb contains log2(sysconf(_SC_PAGESIZE)). When SIGTRAP is delivered in response to a ptrace(2) event (PTRACE_EVENT_foo), si_addr is not populated, but si_pid and si_uid are populated with the respective process ID and user ID responsible for delivering the trap. In the case of seccomp(2), the tracee will be shown as delivering the event. BUS_MCEERR_* and si_addr_lsb are Linux-specific extensions, iykyk ๐
The SEGV_BNDERR suberror of SIGSEGV populates si_lower and si_upper.
The SEGV_PKUERR suberror of SIGSEGV populates si_pkey.
SIGIO/SIGPOLL(the two names are synonyms on Linux, cute right ๐ซถ) fills insi_bandandsi_fd. Thesi_bandevent is a bit mask containing the same values as are filled in thereventsfield bypoll(2). Thesi_fdfield indicates the file descriptor for which the I/O event occurred; for further details, see the description ofF_SETSIGinfcntl(2).SIGSYS, generated (since Linux 3.5) when a seccomp filter returnsSECCOMP_RET_TRAP, fills insi_call_addr,si_syscall,si_arch,si_errno, and other fields as described inseccomp(2).
๐ The si_code field ๐
The si_code field inside the siginfo_t argument that gets passed to a SA_SIGINFO signal handler is a value (not a bit mask, bestie, do not try to mask it ๐ญ) indicating why this signal was sent. For a ptrace(2) event, si_code will contain SIGTRAP and have the ptrace event in the high byte:
(SIGTRAP | PTRACE_EVENT_foo << 8).
For a non-ptrace(2) event, the values that can appear in si_code are described in the rest of this section. Since glibc 2.20, the definitions of most of these symbols are obtained from <signal.h> by defining feature test macros (before including any header file) like this:
_XOPEN_SOURCEwith the value500or greater;_XOPEN_SOURCEand_XOPEN_SOURCE_EXTENDED; or_POSIX_C_SOURCEwith the value200809Lor greater.
For the TRAP_* constants, the symbol definitions are provided only in the first two cases. Before glibc 2.20, no feature test macros were required to obtain these symbols. (the old days were wild, no cap ๐)
For a regular signal, here's the list of values that can be placed in si_code for any signal, along with the reason that signal got generated:
SI_USERโkill(2).SI_KERNELโ sent by the kernel.SI_QUEUEโsigqueue(3).SI_TIMERโ POSIX, orsetitimer(2)oralarm(2)timer expired.SI_MESGQ(since Linux 2.6.6) โ POSIX message queue state changed; seemq_notify(3).SI_ASYNCIOโ AIO completed.SI_SIGIOโ queuedSIGIO(only up to Linux 2.2; from Linux 2.4 onwardSIGIO/SIGPOLLfills insi_codeas described below).SI_TKILL(since Linux 2.4.19) โtkill(2)ortgkill(2).SI_ASYNCNLโ async name lookup completion.
The following values can be placed in si_code for a SIGILL signal:
ILL_ILLOPCโ illegal opcode.ILL_ILLOPNโ illegal operand.ILL_ILLADRโ illegal addressing mode.ILL_ILLTRPโ illegal trap.ILL_PRVOPCโ privileged opcode.ILL_PRVREGโ privileged register.ILL_COPROCโ coprocessor error.ILL_BADSTKโ internal stack error.
The following values can be placed in si_code for a SIGFPE signal:
FPE_INTDIVโ integer divide by zero.FPE_INTOVFโ integer overflow.FPE_FLTDIVโ floating-point divide by zero.FPE_FLTOVFโ floating-point overflow.FPE_FLTUNDโ floating-point underflow.FPE_FLTRESโ floating-point inexact result.FPE_FLTINVโ floating-point invalid operation.FPE_FLTSUBโ subscript out of range.FPE_FLTUNK(since Linux 4.17) โ undiagnosed floating-point exception.FPE_CONDTRAP(PARISC only) โ trap on condition.
The following values can be placed in si_code for a SIGSEGV signal:
SEGV_MAPERRโ address not mapped to object.SEGV_ACCERRโ invalid permissions for mapped object.SEGV_BNDERR(since Linux 3.19) โ failed address bound checks.SEGV_PKUERR(since Linux 4.6) โ access was denied by memory protection keys. Seepkeys(7). The protection key which applied to this access is available viasi_pkey.SEGV_ACCADI(since Linux 4.17; SPARC only) โ Application Data Integrity not enabled for mapped object.SEGV_ADIDERR(since Linux 4.17; SPARC only) โ Disrupting Memory Corruption Detection error.SEGV_ADIPERR(since Linux 4.17; SPARC only) โ Precise Memory Corruption Detection exception.SEGV_MTEAERR(since Linux 5.10; ARM only) โ Asynchronous Memory Tagging Extension error.SEGV_MTESERR(since Linux 5.10; ARM only) โ Synchronous Memory Tagging Extension exception.SEGV_CPERR(since Linux 6.10) โ control protection fault.
The following values can be placed in si_code for a SIGBUS signal:
BUS_ADRALNโ invalid address alignment.BUS_ADRERRโ nonexistent physical address.BUS_OBJERRโ object-specific hardware error.BUS_MCEERR_AR(since Linux 2.6.32) โ hardware memory error consumed on a machine check; action required. ๐จBUS_MCEERR_AO(since Linux 2.6.32) โ hardware memory error detected in process but not consumed; action optional.
The following values can be placed in si_code for a SIGTRAP signal:
TRAP_BRKPTโ process breakpoint.TRAP_TRACEโ process trace trap.TRAP_BRANCH(since Linux 2.4; IA64 only) โ process taken branch trap.TRAP_HWBKPT(since Linux 2.4; IA64 only) โ hardware breakpoint/watchpoint.TRAP_UNK(since Linux 4.18) โ undiagnosed trap.TRAP_PERF(since Linux 5.13 and glibc 2.43) โ perf event withsigtrap=1.
The following values can be placed in si_code for a SIGCHLD signal:
CLD_EXITEDโ child has exited.CLD_KILLEDโ child was killed.CLD_DUMPEDโ child terminated abnormally.CLD_TRAPPEDโ traced child has trapped.CLD_STOPPEDโ child has stopped.CLD_CONTINUED(since Linux 2.6.9) โ stopped child has continued.
The following values can be placed in si_code for a SIGIO/SIGPOLL signal:
POLL_INโ data input available.POLL_OUTโ output buffers available.POLL_MSGโ input message available.POLL_ERRโ I/O error.POLL_PRIโ high priority input available.POLL_HUPโ device disconnected.
The following values can be placed in si_code for a SIGSYS signal:
SYS_SECCOMP(since Linux 3.5 and glibc 2.43) โ triggered by aseccomp(2)filter rule.SYS_USER_DISPATCH(since Linux 5.11 and glibc 2.43) โ syscall user dispatch triggered.
The following value can be placed in si_code for a SIGEMT signal:
EMT_TAGOVF(SPARC only) โ tag overflow.
๐ฆ Dynamically probing for flag bit support ๐ฆ
okay so this part is important, listen up ๐
The sigaction() call on Linux accepts unknown bits set in act->sa_flags without error. The behavior of the kernel starting with Linux 5.11 is that a second sigaction() will clear unknown bits from oldact->sa_flags. However, historically, a second sigaction() call would typically leave those bits set in oldact->sa_flags. (messy era, fr fr ๐)
This means that support for new flags cannot be detected simply by testing for a flag in sa_flags, and a program must test that SA_UNSUPPORTED has been cleared before relying on the contents of sa_flags.
Since the behavior of the signal handler cannot be guaranteed unless the check passes, it is wise to either block the affected signal while registering the handler and performing the check in this case, or where this is not possible โ for example if the signal is synchronous โ to issue the second sigaction() in the signal handler itself.
In kernels that do not support a specific flag, the kernel's behavior is as if the flag was not set, even if the flag was set in act->sa_flags.
The flags SA_NOCLDSTOP, SA_NOCLDWAIT, SA_SIGINFO, SA_ONSTACK, SA_RESTART, SA_NODEFER, SA_RESETHAND, and, if defined by the architecture, SA_RESTORER may not be reliably probed for using this mechanism, because they were introduced before Linux 5.11. However, in general, programs may assume that these flags are supported, since they have all been supported since Linux 2.6, which was released in the year 2003. (yes, ancient, I know ๐ง)
See EXAMPLES below for a demonstration of the use of SA_UNSUPPORTED.
โจ RETURN VALUE โจ
sigaction() returns 0 on success ๐; on error, -1 is returned, and errno is set to indicate the error.
๐ ERRORS ๐
EFAULTโactoroldactpoints to memory which is not a valid part of the process address space.EINVALโ an invalid signal was specified. This will also be generated if an attempt is made to change the action forSIGKILLorSIGSTOP, which cannot be caught or ignored. Not even a little bit. Not even for you, bestie. ๐
โจ VERSIONS โจ
๐ง C library/kernel differences
Okay so bestie, here's the tea about glibc vs the raw kernel syscall ๐
- The glibc wrapper function for
sigaction()gives an error (EINVAL) on attempts to change the disposition of the two real-time signals used internally by the NPTL threading implementation. Seenptl(7)for details. not me touching the thread library's private little signals ๐ don't. - On architectures where the signal trampoline resides in the C library, the glibc wrapper function for
sigaction()places the address of the trampoline code in theact.sa_restorerfield and sets theSA_RESTORERflag in theact.sa_flagsfield. Seesigreturn(2). glibc is out here doing the plumbing for you, iconic behavior honestly ๐ซถ - The original Linux system call was named
sigaction(). However, with the addition of real-time signals in Linux 2.2, the fixed-size, 32-bitsigset_ttype supported by that system call was no longer fit for purpose. Consequently, a new system call,rt_sigaction(), was added to support an enlargedsigset_ttype. The new system call takes a fourth argument,size_t sigsetsize, which specifies the size in bytes of the signal sets inact.sa_maskandoldact.sa_mask. This argument is currently required to have the valuesizeof(sigset_t)(or the errorEINVALresults). The glibcsigaction()wrapper function hides these details from us, transparently callingrt_sigaction()when the kernel provides it. so glibc is basically the bestie who handles the group chat admin duties so you never have to see the mess ๐
๐ STANDARDS ๐
POSIX.1-2024. that's it, that's the standard, periodt โญ
๐ HISTORY ๐
POSIX.1-2001, SVr4.
POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 and later allow this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see wait(2)). Nevertheless, the historical BSD and System V behaviors for ignoring SIGCHLD differ, so that the only completely portable method of ensuring that terminated children do not become zombies is to catch the SIGCHLD signal and perform a wait(2) or similar. yes bestie the only completely portable way โ read it and weep ๐ญ
POSIX.1-1990 specified only SA_NOCLDSTOP. POSIX.1-2001 added SA_NOCLDWAIT, SA_NODEFER, SA_ONSTACK, SA_RESETHAND, SA_RESTART, and SA_SIGINFO as XSI extensions. POSIX.1-2008 moved SA_NODEFER, SA_RESETHAND, SA_RESTART, and SA_SIGINFO to the base specifications. Use of these latter values in sa_flags may be less portable in applications intended for older UNIX implementations. so if you're porting to ancient UNIX, vibe check your flags first ๐ฐ๏ธ
The SA_RESETHAND flag is compatible with the SVr4 flag of the same name.
The SA_NODEFER flag is compatible with the SVr4 flag of the same name under kernels 1.3.9 and later. On older kernels the Linux implementation allowed the receipt of any signal, not just the one we are installing (effectively overriding any sa_mask settings). that's the ancient-kernel chaos era fr fr ๐
๐ NOTES ๐
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. so like, ignored stays ignored, handled gets factory reset. slay โจ
According to POSIX, the behavior of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by kill(2) or raise(3). Integer division by zero has undefined result. On some architectures it will generate a SIGFPE signal. (Also dividing the most negative integer by -1 may generate SIGFPE.) Ignoring this signal might lead to an endless loop. okay this one's a big deal bestie โ ignoring those signals can literally trap you in an endless loop, do not ๐
sigaction() can be called with a NULL second argument to query the current signal handler. It can also be used to check whether a given signal is valid for the current machine by calling it with NULL second and third arguments. peek at the state without changing anything, we love a low-stakes reconnaissance mission ๐
It is not possible to block SIGKILL or SIGSTOP (by specifying them in sa_mask). Attempts to do so are silently ignored. the kernel said no and didn't even tell you. rude but valid ๐
See sigsetops(3) for details on manipulating signal sets.
See signal-safety(7) for a list of the async-signal-safe functions that can be safely called inside from inside a signal handler. (yes, "inside from inside", the original said it like that, i'm just the messenger ๐)
POSIX only guarantees SI_TIMER for signals created by timer_create(2). Implementations are free to also provide it for other types of timers. The Linux behavior matches NetBSD.
๐ธ Undocumented
Before the introduction of SA_SIGINFO, it was also possible to get some additional information about the signal. This was done by providing an sa_handler signal handler with a second argument of type struct sigcontext, which is the same structure as the one that is passed in the uc_mcontext field of the ucontext structure that is passed (via a pointer) in the third argument of the sa_sigaction handler. See the relevant Linux kernel sources for details. This use is obsolete now. ancient lore, look but don't touch ๐ซฃ
๐ญ BUGS ๐ญ
When delivering a signal resulting from a hardware exception with a SA_SIGINFO handler, the kernel does not always provide meaningful values for all of the fields of the siginfo_t that are relevant for that signal. For example, when the x86 int instruction is called with a forbidden argument (any number other than 3 or 128), a SIGSEGV signal is delivered, but the siginfo_t passed to the signal handler has all its fields besides si_signo and si_code set to zero, even if other fields should be set (as an example, si_addr should be non-zero for all SIGSEGV signals). not the kernel handing you a blank sheet of paper and calling it a report ๐
Up to and including Linux 2.6.13, specifying SA_NODEFER in sa_flags prevents not only the delivered signal from being masked during execution of the handler, but also the signals specified in sa_mask. This bug was fixed in Linux 2.6.14.
๐ฅ EXAMPLES ๐ฅ
See mprotect(2).
โญ Probing for flag support
The following example program exits with status EXIT_SUCCESS if SA_EXPOSE_TAGBITS is determined to be supported, and EXIT_FAILURE otherwise.
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void
handler(int signo, siginfo_t *info, void *context)
{
struct sigaction oldact;
if (sigaction(SIGSEGV, NULL, &oldact) == -1
|| (oldact.sa_flags & SA_UNSUPPORTED)
|| !(oldact.sa_flags & SA_EXPOSE_TAGBITS))
{
_exit(EXIT_FAILURE);
}
_exit(EXIT_SUCCESS);
}
int
main(void)
{
struct sigaction act = { 0 };
act.sa_flags = SA_SIGINFO | SA_UNSUPPORTED | SA_EXPOSE_TAGBITS;
act.sa_sigaction = &handler;
if (sigaction(SIGSEGV, &act, NULL) == -1) {
perror("sigaction");
exit(EXIT_FAILURE);
}
raise(SIGSEGV);
}
๐ฆ SEE ALSO ๐ฆ
kill(1), kill(2), pause(2), pidfd_send_signal(2), restart_syscall(2), seccomp(2), sigaltstack(2), signal(2), signalfd(2), sigpending(2), sigprocmask(2), sigreturn(2), sigsuspend(2), wait(2), killpg(3), raise(3), siginterrupt(3), sigqueue(3), sigsetops(3), sigvec(3), core(5), signal(7)
and that's the whole thing bestie, you made it to the end of sigaction(2) ๐ฅณ๐ซถ this edition is from Linux man-pages 6.20, dated 2026-02-08 โ go forth and handle your signals responsibly, ily, bye ๐โจ
๐ฆ 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
- Copyright 1994-1995, Mike Battersby <mib@deakin.edu.au>
- Copyright 2004-2005, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms