2002-06-10 03:00:24 +00:00
|
|
|
.\"
|
|
|
|
.\" 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 form must reproduce the above copyright
|
|
|
|
.\" notice(s), this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
|
|
|
|
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
|
|
|
|
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
.\" DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2004-11-20 02:11:42 +00:00
|
|
|
.Dd November 20, 2004
|
2002-06-10 03:00:24 +00:00
|
|
|
.Dt SIGNAL 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2004-07-05 17:12:53 +00:00
|
|
|
.Nm signal ,
|
2002-06-10 03:00:24 +00:00
|
|
|
.Nm SIGADDSET ,
|
|
|
|
.Nm SIGDELSET ,
|
|
|
|
.Nm SETEMPTYSET ,
|
|
|
|
.Nm SIGFILLSET ,
|
|
|
|
.Nm SIGISMEMBER ,
|
|
|
|
.Nm SIGISEMPTY ,
|
2004-07-05 17:12:53 +00:00
|
|
|
.Nm SIGNOTEMPTY ,
|
2002-06-10 03:00:24 +00:00
|
|
|
.Nm SIGSETEQ ,
|
|
|
|
.Nm SIGSETNEQ ,
|
|
|
|
.Nm SIGSETOR ,
|
|
|
|
.Nm SIGSETAND ,
|
|
|
|
.Nm SIGSETNAND ,
|
|
|
|
.Nm SIGSETCANTMASK ,
|
|
|
|
.Nm SIG_STOPSIGMASK ,
|
|
|
|
.Nm SIG_CONTSIGMASK ,
|
|
|
|
.Nm SIGPENDING ,
|
2004-11-20 02:11:42 +00:00
|
|
|
.Nm cursig ,
|
2002-06-10 03:00:24 +00:00
|
|
|
.Nm execsigs ,
|
|
|
|
.Nm issignal ,
|
|
|
|
.Nm killproc ,
|
|
|
|
.Nm pgsigio ,
|
|
|
|
.Nm postsig ,
|
|
|
|
.Nm sigexit ,
|
|
|
|
.Nm siginit ,
|
|
|
|
.Nm signotify ,
|
|
|
|
.Nm trapsignal
|
|
|
|
.Nd "kernel signal functions"
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.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
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn cursig "struct thread *td"
|
2002-06-10 03:00:24 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn execsigs "struct proc *p"
|
|
|
|
.Ft int
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn issignal "struct thread *td"
|
2002-06-10 03:00:24 +00:00
|
|
|
.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
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn signotify "struct thread *td"
|
2002-06-10 03:00:24 +00:00
|
|
|
.Ft void
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn trapsignal "struct thread *td" "int sig" "u_long code"
|
2002-06-10 03:00:24 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn SIGADDSET
|
|
|
|
macro adds
|
|
|
|
.Fa signo
|
|
|
|
to
|
|
|
|
.Fa set .
|
|
|
|
No effort is made to ensure that
|
|
|
|
.Fa signo
|
|
|
|
is a valid signal number.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGDELSET
|
|
|
|
macro removes
|
|
|
|
.Fa signo
|
|
|
|
from
|
|
|
|
.Fa set .
|
|
|
|
No effort is made to ensure that
|
|
|
|
.Fa signo
|
|
|
|
is a valid signal number.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGEMPTYSET
|
|
|
|
macro clears all signals in
|
|
|
|
.Fa set .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGFILLSET
|
|
|
|
macro sets all signals in
|
|
|
|
.Fa set .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGISMEMBER
|
|
|
|
macro determines if
|
|
|
|
.Fa signo
|
|
|
|
is set in
|
|
|
|
.Fa set .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGISEMPTY
|
|
|
|
macro determines if
|
|
|
|
.Fa set
|
|
|
|
does not have any signals set.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGNOTEMPTY
|
|
|
|
macro determines if
|
|
|
|
.Fa set
|
|
|
|
has any signals set.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGSETEQ
|
|
|
|
macro determines if two signal sets are equal; that is, the same signals
|
|
|
|
are set in both.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGSETNEQ
|
|
|
|
macro determines if two signal sets differ; that is, if any signal set in
|
|
|
|
one is not set in the other.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGSETOR
|
2004-07-08 10:47:13 +00:00
|
|
|
macro ORs the signals set in
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fa set2
|
|
|
|
into
|
|
|
|
.Fa set1 .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGSETAND
|
2004-07-08 10:47:13 +00:00
|
|
|
macro ANDs the signals set in
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fa set2
|
|
|
|
into
|
|
|
|
.Fa set1 .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIGSETNAND
|
2004-07-08 10:47:13 +00:00
|
|
|
macro NANDs the signals set in
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fa set2
|
|
|
|
into
|
|
|
|
.Fa set1 .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIG_CANTMASK
|
|
|
|
macro clears the
|
|
|
|
.Dv SIGKILL
|
|
|
|
and
|
|
|
|
.Dv 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.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIG_STOPSIGMASK
|
|
|
|
macro clears the
|
|
|
|
.Dv SIGSTOP ,
|
|
|
|
.Dv SIGTSTP ,
|
|
|
|
.Dv SIGTTIN ,
|
|
|
|
and
|
|
|
|
.Dv 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.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn SIG_CONTSIGMASK
|
|
|
|
macro clears the
|
|
|
|
.Dv SIGCONT
|
|
|
|
signal from
|
|
|
|
.Fa set .
|
|
|
|
.Fn SIG_CONTSIGMASK
|
2004-07-08 10:47:13 +00:00
|
|
|
is called when a process is stopped.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
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
|
2004-07-08 10:47:13 +00:00
|
|
|
traced,
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fn SIGPENDING
|
|
|
|
will return true even if the signal is masked.
|
|
|
|
.Pp
|
|
|
|
The
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn cursig
|
|
|
|
function returns the signal number that should be delivered to process
|
|
|
|
.Fa td->td_proc .
|
2004-07-08 10:47:13 +00:00
|
|
|
If there are no signals pending, zero is returned.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn execsigs
|
|
|
|
function resets the signal set and signal stack of a process in preparation
|
|
|
|
for an
|
2004-07-08 10:47:13 +00:00
|
|
|
.Xr execve 2 .
|
2002-06-10 03:00:24 +00:00
|
|
|
The lock for
|
|
|
|
.Fa p
|
|
|
|
must be held before
|
|
|
|
.Fn execsigs
|
|
|
|
is called.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn issignal
|
2004-11-20 02:11:42 +00:00
|
|
|
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
|
2002-06-10 03:00:24 +00:00
|
|
|
current system call.
|
2004-11-20 02:11:42 +00:00
|
|
|
If process
|
|
|
|
.Fa td->td_proc
|
|
|
|
is currently being traced, ignored signals will be handled and the process
|
2002-06-10 03:00:24 +00:00
|
|
|
is always stopped.
|
|
|
|
Stop signals are handled and cleared right away by
|
2004-11-20 02:11:42 +00:00
|
|
|
.Fn issignal
|
2002-06-10 03:00:24 +00:00
|
|
|
unless the process is a member of an orphaned process group and the stop
|
2004-07-08 10:47:13 +00:00
|
|
|
signal originated from a TTY.
|
|
|
|
The
|
|
|
|
.Va sched_lock
|
2004-11-20 02:11:42 +00:00
|
|
|
lock may be acquired and released, and if
|
2004-07-08 10:47:13 +00:00
|
|
|
.Va Giant
|
|
|
|
is held, it may be released and reacquired.
|
2004-11-20 02:11:42 +00:00
|
|
|
The
|
|
|
|
.Vt sigacts
|
|
|
|
structure
|
|
|
|
.Fa td->td_proc->p_sigacts
|
|
|
|
must be locked before calling
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fn issignal
|
2004-11-20 02:11:42 +00:00
|
|
|
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.
|
|
|
|
The lock for the parent of
|
|
|
|
.Fa td->td_proc
|
|
|
|
may also be acquired and released.
|
2002-06-10 03:00:24 +00:00
|
|
|
Default signal actions are not taken for system processes and init.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn killproc
|
|
|
|
function delivers
|
2004-07-08 10:47:13 +00:00
|
|
|
.Dv SIGKILL
|
|
|
|
to
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fa p .
|
|
|
|
.Fa why
|
2004-07-08 10:47:13 +00:00
|
|
|
is logged as the reason
|
|
|
|
.Em why
|
|
|
|
the process was killed.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn pgsigio
|
|
|
|
function sends the signal
|
|
|
|
.Fa sig
|
|
|
|
to the process or process group
|
|
|
|
.Fa sigiop->sio_pgid .
|
|
|
|
If
|
|
|
|
.Fa checkctty
|
2004-07-08 10:47:13 +00:00
|
|
|
is non-zero, the signal is only delivered to processes in the process group
|
2002-06-10 03:00:24 +00:00
|
|
|
that have a controlling terminal.
|
|
|
|
If
|
2004-07-08 10:47:13 +00:00
|
|
|
.Fa sigiop->sio_pgid
|
2003-05-18 21:05:22 +00:00
|
|
|
is for a process (> 0), the lock for
|
2004-07-08 10:47:13 +00:00
|
|
|
.Fa sigiop->sio_proc
|
2002-06-10 03:00:24 +00:00
|
|
|
is acquired and released.
|
|
|
|
If
|
2004-07-08 10:47:13 +00:00
|
|
|
.Fa sigiop->sio_pgid
|
2003-05-18 21:05:22 +00:00
|
|
|
is for a process group (< 0), the process group lock for
|
2004-07-08 10:47:13 +00:00
|
|
|
.Fa sigiop->sio_pgrp
|
2002-06-10 03:00:24 +00:00
|
|
|
is acquired and released.
|
2004-11-20 02:11:42 +00:00
|
|
|
The lock
|
|
|
|
.Va sigio_lock
|
2002-06-10 03:00:24 +00:00
|
|
|
is acquired and released.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn postsig
|
|
|
|
function handles the actual delivery of the signal
|
|
|
|
.Fa sig .
|
|
|
|
.Fn postsig
|
2003-09-14 13:41:59 +00:00
|
|
|
is called from
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fn ast
|
|
|
|
after the kernel has been notified that a signal should be delivered
|
|
|
|
(via a call to
|
|
|
|
.Fn signotify ,
|
|
|
|
which causes the flag
|
|
|
|
.Dv PS_NEEDSIGCHK
|
|
|
|
to be set).
|
|
|
|
The lock for process that owns
|
|
|
|
.Va curthread
|
|
|
|
must be held before
|
|
|
|
.Fn postsig
|
|
|
|
is called, and the current process cannot be 0.
|
2004-11-20 02:11:42 +00:00
|
|
|
The lock for the
|
|
|
|
.Va p_sigacts
|
|
|
|
field of the current process must be held before
|
|
|
|
.Fn postsig
|
|
|
|
is called, and may be released and reacquired.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn sigexit
|
|
|
|
function causes the process that owns
|
|
|
|
.Fa td
|
|
|
|
to exit with a return value of signal number
|
2004-07-08 10:47:13 +00:00
|
|
|
.Fa sig .
|
2002-06-10 03:00:24 +00:00
|
|
|
If required, the process will dump core.
|
|
|
|
The lock for the process that owns
|
|
|
|
.Fa td
|
|
|
|
must be held before
|
|
|
|
.Fn sigexit
|
2004-11-20 02:11:42 +00:00
|
|
|
is called.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn siginit
|
2002-09-07 06:07:55 +00:00
|
|
|
function is called during system initialization to cause every signal with
|
|
|
|
a default property of
|
|
|
|
.Dv SA_IGNORE
|
|
|
|
(except
|
|
|
|
.Dv SIGCONT )
|
|
|
|
to be ignored by
|
|
|
|
.Fa p .
|
|
|
|
The process lock for
|
|
|
|
.Fa p
|
|
|
|
is acquired and released by
|
|
|
|
.Fn siginit .
|
|
|
|
The only process that
|
|
|
|
.Fn siginit
|
|
|
|
is ever called for
|
|
|
|
is
|
2004-07-08 10:47:13 +00:00
|
|
|
.Va proc0 .
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn signotify
|
|
|
|
function flags that there are unmasked signals pending that
|
|
|
|
.Fn ast
|
|
|
|
should handle.
|
2004-11-20 02:11:42 +00:00
|
|
|
The lock for process
|
|
|
|
.Fa td->td_proc
|
2002-06-10 03:00:24 +00:00
|
|
|
must be held before
|
|
|
|
.Fn signotify
|
|
|
|
is called, and
|
2004-07-08 10:47:13 +00:00
|
|
|
.Va sched_lock
|
2002-06-10 03:00:24 +00:00
|
|
|
is acquired and released.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn trapsignal
|
2004-11-20 02:11:42 +00:00
|
|
|
function sends a signal that is the result of a trap to process
|
|
|
|
.Fa td->td_proc .
|
2002-06-10 03:00:24 +00:00
|
|
|
If the process is not being traced and the signal can be delivered
|
2004-07-08 10:47:13 +00:00
|
|
|
immediately,
|
2002-06-10 03:00:24 +00:00
|
|
|
.Fn trapsignal
|
|
|
|
will deliver it directly; otherwise,
|
|
|
|
.Fn trapsignal
|
|
|
|
will call
|
|
|
|
.Xr psignal 9
|
2002-06-10 17:08:42 +00:00
|
|
|
to cause the signal to be delivered.
|
2004-11-20 02:11:42 +00:00
|
|
|
The
|
|
|
|
.Va sched_lock
|
|
|
|
lock is acquired and released, as is the lock for
|
|
|
|
.Fa td->td_proc .
|
|
|
|
The lock for the
|
|
|
|
.Va p_sigacts
|
|
|
|
field of
|
|
|
|
.Fa td->td_proc
|
|
|
|
is acquired and released.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
|
|
|
.Fn SIGISMEMBER ,
|
|
|
|
.Fn SIGISEMPTY ,
|
|
|
|
.Fn SIGNOTEMPTY ,
|
|
|
|
.Fn SIGSETEQ ,
|
|
|
|
.Fn SIGSETNEQ ,
|
|
|
|
and
|
|
|
|
.Fn SIGPENDING
|
2004-07-08 10:47:13 +00:00
|
|
|
macros all return non-zero (true) if the condition they are checking
|
2002-06-10 03:00:24 +00:00
|
|
|
is found to be true; otherwise, zero (false) is returned.
|
|
|
|
.Pp
|
2004-11-20 02:11:42 +00:00
|
|
|
The
|
|
|
|
.Fn cursig
|
|
|
|
function returns either a valid signal number or zero.
|
2002-06-10 03:00:24 +00:00
|
|
|
.Pp
|
|
|
|
.Fn issignal
|
|
|
|
returns either a valid signal number or zero.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr gsignal 9 ,
|
|
|
|
.Xr pgsignal 9 ,
|
|
|
|
.Xr psignal 9
|
|
|
|
.Sh AUTHORS
|
|
|
|
This man page was written by
|
|
|
|
.An Chad David Aq davidc@FreeBSD.org .
|