SIGNAL(9)
π SIGNAL(9) β Kernel Developer's Manual π
okay so bestie, welcome to SIGNAL(9), the kernel signal functions page from the Kernel Developerβs Manual. This is the whole signal-wrangling squad: macros for poking at signal sets, functions for delivering signals, and all the locking lore that comes with them. no cap, itβs iconic kernel plumbing. π
β¨ NAME β¨
signal, SIGADDSET, SIGDELSET, SETEMPTYSET, SIGFILLSET, SIGISMEMBER, SIGISEMPTY, SIGNOTEMPTY, SIGSETEQ, SIGSETNEQ, SIGSETOR, SIGSETAND, SIGSETNAND, SIGSETCANTMASK, SIG_STOPSIGMASK, SIG_CONTSIGMASK, SIGPENDING, cursig, execsigs, issignal, killproc, pgsigio, postsig, sigexit, siginit, signotify, trapsignal β kernel signal functions.
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
void
SIGADDSET(sigset_t set, int signo);
void
SIGDELSET(sigset_t set, int signo);
void
SIGEMPTYSET(sigset_t set);
void
SIGFILLSET(sigset_t set);
int
SIGISMEMBER(sigset_t set, int signo);
int
SIGISEMPTY(sigset_t set);
int
SIGNOTEMPTY(sigset_t set);
int
SIGSETEQ(sigset_t set1, sigset_t set2);
int
SIGSETNEQ(sigset_t set1, sigset_t set2);
void
SIGSETOR(sigset_t set1, sigset_t set2);
void
SIGSETAND(sigset_t set1, sigset_t set2);
void
SIGSETNAND(sigset_t set1, sigset_t set2);
void
SIG_CANTMASK(sigset_t set);
void
SIG_STOPSIGMASK(sigset_t set);
void
SIG_CONTSIGMASK(sigset_t set);
int
SIGPENDING(struct proc *p);
int
cursig(struct thread *td);
void
execsigs(struct proc *p);
int
issignal(struct thread *td);
void
killproc(struct proc *p, char *why);
void
pgsigio(struct sigio **sigiop, int sig, int checkctty);
void
postsig(int sig);
void
sigexit(struct thread *td, int signum);
void
siginit(struct proc *p);
void
signotify(struct thread *td);
void
trapsignal(struct thread *td, int sig, u_long code);
π DESCRIPTION π
SIGADDSET()β addssignotoset. And lol, no effort is made to ensure thatsignois a valid signal number. itβs giving βtrust me broβ.SIGDELSET()β removessignofromset. Same energy: no effort is made to ensure thatsignois a valid signal number.SIGEMPTYSET()β clears all signals inset. Empty set, clean slate, main character reset β¨.SIGFILLSET()β sets all signals inset. Full set, no crumbs.SIGISMEMBER()β determines ifsignois set inset.SIGISEMPTY()β determines ifsetdoes not have any signals set.SIGNOTEMPTY()β determines ifsethas any signals set.SIGSETEQ()β determines if two signal sets are equal; that is, the same signals are set in both.SIGSETNEQ()β determines if two signal sets differ; that is, if any signal set in one is not set in the other.SIGSETOR()β ORs the signals set inset2intoset1.SIGSETAND()β ANDs the signals set inset2intoset1.SIGSETNAND()β NANDs the signals set inset2intoset1.SIG_CANTMASK()β clears theSIGKILLandSIGSTOPsignals fromset. These two signals cannot be blocked or caught, andSIG_CANTMASK()is used in code where signals are manipulated to ensure this policy is enforced. this is a hard boundary, bestie.SIG_STOPSIGMASK()β clears theSIGSTOP,SIGTSTP,SIGTTIN, andSIGTTOUsignals fromset.SIG_STOPSIGMASK()is used to clear stop signals when a process is waiting for a child to exit or exec, and when a process is continuing after having been suspended.SIG_CONTSIGMASK()β clears theSIGCONTsignal fromset.SIG_CONTSIGMASK()is called when a process is stopped.SIGPENDING()β determines if the given process has any pending signals that are not masked. If the process has a pending signal and the process is currently being traced,SIGPENDING()will return true even if the signal is masked. sneaky but documented.cursig()β returns the signal number that should be delivered to processtd->td_proc. If there are no signals pending, zero is returned.execsigs()β resets the signal set and signal stack of a process in preparation forexecve(2). The process lock forpmust be held beforeexecsigs()is called.issignal()β determines if there are any pending signals for processtd->td_procthat should be caught, or cause this process to terminate or interrupt its current system call. If processtd->td_procis currently being traced, ignored signals will be handled and the process is always stopped. Stop signals are handled and cleared right away byissignal()unless the process is a member of an orphaned process group and the stop signal originated from a TTY. The process spin lock fortd->td_procmay be acquired and released. Thesigactsstructuretd->td_proc->p_sigactsmust be locked before callingissignal()and may be released and reacquired during the call. The process lock fortd->td_procmust be acquired before callingissignal()and may be released and reacquired during the call. Default signal actions are not taken for system processes and init. locking lore unlocked π.killproc()β deliversSIGKILLtop.whyis logged as the reason why the process was killed. bye bestie, and itβs on the record.pgsigio()β sends the signalsigto the process or process groupsigiop->sio_pgid. Ifcheckcttyis non-zero, the signal is only delivered to processes in the process group that have a controlling terminal. Ifsigiop->sio_pgidis for a process (> 0), the lock forsigiop->sio_procis acquired and released. Ifsigiop->sio_pgidis for a process group (< 0), the process group lock forsigiop->sio_pgrpis acquired and released. The locksigio_lockis acquired and released.postsig()β handles the actual delivery of the signalsig.postsig()is called fromast()after the kernel has been notified that a signal should be delivered (via a call tosignotify(), which causes the flagPS_NEEDSIGCHKto be set). The process lock for process that ownscurthreadmust be held beforepostsig()is called, and the current process cannot be0. The lock for thep_sigactsfield of the current process must be held beforepostsig()is called, and may be released and reacquired.sigexit()β causes the process that ownstdto exit with a return value of signal numbersig. If required, the process will dump core. The process lock for the process that ownstdmust be held beforesigexit()is called.siginit()β is called during system initialization to cause every signal with a default property ofSA_IGNORE(exceptSIGCONT) to be ignored byp. The process lock forpis acquired and released, as is the lock forsigactsstructurep->p_sigacts. The only process thatsiginit()is ever called for isproc0. special little boot-time behavior.signotify()β flags that there are unmasked signals pending thatast()should handle. The process lock for processtd->td_procmust be held beforesignotify()is called, and the thread lock is acquired and released.trapsignal()β sends a signal that is the result of a trap to processtd->td_proc. If the process is not being traced and the signal can be delivered immediately,trapsignal()will deliver it directly; otherwise,trapsignal()will callpsignal(9)to cause the signal to be delivered. The process lock fortd->td_procis acquired and released. The lock for thep_sigactsfield oftd->td_procis acquired and released.
π RETURN VALUES π
The SIGISMEMBER(), SIGISEMPTY(), SIGNOTEMPTY(), SIGSETEQ(), SIGSETNEQ(), and SIGPENDING() macros all return non-zero (true) if the condition they are checking is found to be true; otherwise, zero (false) is returned.
The cursig() function returns either a valid signal number or zero.
issignal() returns either a valid signal number or zero.
π¦ SEE ALSO π¦
pgsignal(9), psignal(9) β go read the friends, iykyk π.
π AUTHORS π
This manual page was written by Chad David <davidc@FreeBSD.org>.
xoxo bestie π β Debian β July 14, 2023 β SIGNAL(9) π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (C) 2002 Chad David <davidc@FreeBSD.org>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms