SETSETOR (9)
Leading comments
Copyright (C) 2002 Chad David <davidc@FreeBSD.org>. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice(s), this list of conditions and the following disclaimer as the first lines of this file unmodified other than the possible addition of one or more copyright notices. 2. Redistributions in binary fo...
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 functionsSYNOPSIS
In sys/param.h In sys/proc.h In sys/signalvar.h Ft void Fn SIGADDSET sigset_t set int signo Ft void Fn SIGDELSET sigset_t set int signo Ft void Fn SIGEMPTYSET sigset_t set Ft void Fn SIGFILLSET sigset_t set Ft int Fn SIGISMEMBER sigset_t set int signo Ft int Fn SIGISEMPTY sigset_t set Ft int Fn SIGNOTEMPTY sigset_t set Ft int Fn SIGSETEQ sigset_t set1 sigset_t set2 Ft int Fn SIGSETNEQ sigset_t set1 sigset_t set2 Ft void Fn SIGSETOR sigset_t set1 sigset_t set2 Ft void Fn SIGSETAND sigset_t set1 sigset_t set2 Ft void Fn SIGSETNAND sigset_t set1 sigset_t set2 Ft void Fn SIG_CANTMASK sigset_t set Ft void Fn SIG_STOPSIGMASK sigset_t set Ft void Fn SIG_CONTSIGMASK sigset_t set Ft int Fn SIGPENDING struct proc *p Ft int Fn cursig struct thread *td Ft void Fn execsigs struct proc *p Ft int Fn issignal struct thread *td Ft void Fn killproc struct proc *p char *why Ft void Fn pgsigio struct sigio **sigiop int sig int checkctty Ft void Fn postsig int sig Ft void Fn sigexit struct thread *td int signum Ft void Fn siginit struct proc *p Ft void Fn signotify struct thread *td Ft void Fn trapsignal struct thread *td int sig u_long codeDESCRIPTION
The Fn SIGADDSET macro adds Fa signo to Fa set . No effort is made to ensure that Fa signo is a valid signal number.The Fn SIGDELSET macro removes Fa signo from Fa set . No effort is made to ensure that Fa signo is a valid signal number.
The Fn SIGEMPTYSET macro clears all signals in Fa set .
The Fn SIGFILLSET macro sets all signals in Fa set .
The Fn SIGISMEMBER macro determines if Fa signo is set in Fa set .
The Fn SIGISEMPTY macro determines if Fa set does not have any signals set.
The Fn SIGNOTEMPTY macro determines if Fa set has any signals set.
The Fn SIGSETEQ macro determines if two signal sets are equal; that is, the same signals are set in both.
The Fn SIGSETNEQ macro determines if two signal sets differ; that is, if any signal set in one is not set in the other.
The Fn SIGSETOR macro ORs the signals set in Fa set2 into Fa set1 .
The Fn SIGSETAND macro ANDs the signals set in Fa set2 into Fa set1 .
The Fn SIGSETNAND macro NANDs the signals set in Fa set2 into Fa set1 .
The Fn SIG_CANTMASK macro clears the SIGKILL and SIGSTOP signals from Fa set . These two signals cannot be blocked or caught and Fn SIG_CANTMASK is used in code where signals are manipulated to ensure this policy is enforced.
The Fn SIG_STOPSIGMASK macro clears the SIGSTOP SIGTSTP SIGTTIN and SIGTTOU signals from Fa set . Fn 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.
The Fn SIG_CONTSIGMASK macro clears the SIGCONT signal from Fa set . Fn SIG_CONTSIGMASK is called when a process is stopped.
The Fn SIGPENDING macro 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, Fn SIGPENDING will return true even if the signal is masked.
The Fn cursig function returns the signal number that should be delivered to process Fa td->td_proc . If there are no signals pending, zero is returned.
The Fn execsigs function resets the signal set and signal stack of a process in preparation for an execve(2). The process lock for Fa p must be held before Fn execsigs is called.
The Fn issignal function determines if there are any pending signals for process Fa td->td_proc that should be caught, or cause this process to terminate or interrupt its current system call. If process Fa td->td_proc is currently being traced, ignored signals will be handled and the process is always stopped. Stop signals are handled and cleared right away by Fn issignal unless the process is a member of an orphaned process group and the stop signal originated from a TTY. The process spin lock for Fa td->td_proc may be acquired and released. The Vt sigacts structure Fa td->td_proc->p_sigacts must be locked before calling Fn issignal and may be released and reacquired during the call. The process lock for Fa td->td_proc must be acquired before calling Fn issignal and may be released and reacquired during the call. Default signal actions are not taken for system processes and init.
The Fn killproc function delivers SIGKILL to Fa p . Fa why is logged as the reason why the process was killed.
The Fn pgsigio function sends the signal Fa sig to the process or process group Fa sigiop->sio_pgid . If Fa checkctty is non-zero, the signal is only delivered to processes in the process group that have a controlling terminal. If Fa sigiop->sio_pgid is for a process (> 0), the lock for Fa sigiop->sio_proc is acquired and released. If Fa sigiop->sio_pgid is for a process group (< 0), the process group lock for Fa sigiop->sio_pgrp is acquired and released. The lock sigio_lock is acquired and released.
The Fn postsig function handles the actual delivery of the signal Fa sig . Fn postsig is called from Fn ast after the kernel has been notified that a signal should be delivered (via a call to Fn signotify , which causes the flag PS_NEEDSIGCHK to be set). The process lock for process that owns curthread must be held before Fn postsig is called, and the current process cannot be 0. The lock for the p_sigacts field of the current process must be held before Fn postsig is called, and may be released and reacquired.
The Fn sigexit function causes the process that owns Fa td to exit with a return value of signal number Fa sig . If required, the process will dump core. The process lock for the process that owns Fa td must be held before Fn sigexit is called.
The Fn siginit function is called during system initialization to cause every signal with a default property of SA_IGNORE (except SIGCONT to be ignored by Fa p . The process lock for Fa p is acquired and released, as is the lock for sigacts structure Fa p->p_sigacts . The only process that Fn siginit is ever called for is proc0
The Fn signotify function flags that there are unmasked signals pending that Fn ast should handle. The process lock for process Fa td->td_proc must be held before Fn signotify is called, and the thread lock is acquired and released.
The Fn trapsignal function sends a signal that is the result of a trap to process Fa td->td_proc . If the process is not being traced and the signal can be delivered immediately, Fn trapsignal will deliver it directly; otherwise, Fn trapsignal will call psignal(9) to cause the signal to be delivered. The process lock for Fa td->td_proc is acquired and released. The lock for the p_sigacts field of Fa td->td_proc is acquired and released.
RETURN VALUES
The Fn SIGISMEMBER , Fn SIGISEMPTY , Fn SIGNOTEMPTY , Fn SIGSETEQ , Fn SIGSETNEQ , and Fn SIGPENDING macros all return non-zero (true) if the condition they are checking is found to be true; otherwise, zero (false) is returned.The Fn cursig function returns either a valid signal number or zero.
Fn issignal returns either a valid signal number or zero.