blob: f7ca776ed0be15d5b71a35bf5ff99347c2d10d30 [file] [log] [blame]
.\" Copyright (c) 2005 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
.TH SIGVEC 3 2021-03-22 "Linux" "Linux Programmer's Manual"
.SH NAME
sigvec, sigblock, sigsetmask, siggetmask, sigmask \- BSD signal API
.SH SYNOPSIS
.nf
.B #include <signal.h>
.PP
.BI "int sigvec(int " sig ", const struct sigvec *" vec ", struct sigvec *" ovec );
.PP
.BI "int sigmask(int " signum );
.PP
.BI "int sigblock(int " mask );
.BI "int sigsetmask(int " mask );
.B int siggetmask(void);
.fi
.PP
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.PP
All functions shown above:
.nf
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_BSD_SOURCE
.fi
.SH DESCRIPTION
These functions are provided in glibc as a compatibility interface
for programs that make use of the historical BSD signal API.
This API is obsolete: new applications should use the POSIX signal API
.RB ( sigaction (2),
.BR sigprocmask (2),
etc.).
.PP
The
.BR sigvec ()
function sets and/or gets the disposition of the signal
.I sig
(like the POSIX
.BR sigaction (2)).
If
.I vec
is not NULL, it points to a
.I sigvec
structure that defines the new disposition for
.IR sig .
If
.I ovec
is not NULL, it points to a
.I sigvec
structure that is used to return the previous disposition of
.IR sig .
To obtain the current disposition of
.I sig
without changing it, specify NULL for
.IR vec ,
and a non-null pointer for
.IR ovec .
.PP
The dispositions for
.B SIGKILL
and
.B SIGSTOP
cannot be changed.
.PP
The
.I sigvec
structure has the following form:
.PP
.in +4n
.EX
struct sigvec {
void (*sv_handler)(int); /* Signal disposition */
int sv_mask; /* Signals to be blocked in handler */
int sv_flags; /* Flags */
};
.EE
.in
.PP
The
.I sv_handler
field specifies the disposition of the signal, and is either:
the address of a signal handler function;
.BR SIG_DFL ,
meaning the default disposition applies for the signal; or
.BR SIG_IGN ,
meaning that the signal is ignored.
.PP
If
.I sv_handler
specifies the address of a signal handler, then
.I sv_mask
specifies a mask of signals that are to be blocked while
the handler is executing.
In addition, the signal for which the handler is invoked is
also blocked.
Attempts to block
.B SIGKILL
or
.B SIGSTOP
are silently ignored.
.PP
If
.I sv_handler
specifies the address of a signal handler, then the
.I sv_flags
field specifies flags controlling what happens when the handler is called.
This field may contain zero or more of the following flags:
.TP
.B SV_INTERRUPT
If the signal handler interrupts a blocking system call,
then upon return from the handler the system call s not be restarted:
instead it fails with the error
.BR EINTR .
If this flag is not specified, then system calls are restarted
by default.
.TP
.B SV_RESETHAND
Reset the disposition of the signal to the default
before calling the signal handler.
If this flag is not specified, then the handler remains established
until explicitly removed by a later call to
.BR sigvec ()
or until the process performs an
.BR execve (2).
.TP
.B SV_ONSTACK
Handle the signal on the alternate signal stack
(historically established under BSD using the obsolete
.BR sigstack ()
function; the POSIX replacement is
.BR sigaltstack (2)).
.PP
The
.BR sigmask ()
macro constructs and returns a "signal mask" for
.IR signum .
For example, we can initialize the
.I vec.sv_mask
field given to
.BR sigvec ()
using code such as the following:
.PP
.in +4n
.EX
vec.sv_mask = sigmask(SIGQUIT) | sigmask(SIGABRT);
/* Block SIGQUIT and SIGABRT during
handler execution */
.EE
.in
.PP
The
.BR sigblock ()
function adds the signals in
.I mask
to the process's signal mask
(like POSIX
.IR sigprocmask(SIG_BLOCK) ),
and returns the process's previous signal mask.
Attempts to block
.B SIGKILL
or
.B SIGSTOP
are silently ignored.
.PP
The
.BR sigsetmask ()
function sets the process's signal mask to the value given in
.I mask
(like POSIX
.IR sigprocmask(SIG_SETMASK) ),
and returns the process's previous signal mask.
.PP
The
.BR siggetmask ()
function returns the process's current signal mask.
This call is equivalent to
.IR sigblock(0) .
.SH RETURN VALUE
The
.BR sigvec ()
function returns 0 on success; on error, it returns \-1 and sets
.I errno
to indicate the error.
.PP
The
.BR sigblock ()
and
.BR sigsetmask ()
functions return the previous signal mask.
.PP
The
.BR sigmask ()
macro returns the signal mask for
.IR signum .
.SH ERRORS
See the ERRORS under
.BR sigaction (2)
and
.BR sigprocmask (2).
.SH VERSIONS
Starting with version 2.21, the GNU C library no longer exports the
.BR sigvec ()
function as part of the ABI.
(To ensure backward compatibility,
the glibc symbol versioning scheme continues to export the interface
to binaries linked against older versions of the library.)
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.ad l
.nh
.TS
allbox;
lbx lb lb
l l l.
Interface Attribute Value
T{
.BR sigvec (),
.BR sigmask (),
.BR sigblock (),
.BR sigsetmask (),
.BR siggetmask ()
T} Thread safety MT-Safe
.TE
.hy
.ad
.sp 1
.SH CONFORMING TO
All of these functions were in
4.3BSD, except
.BR siggetmask (),
whose origin is unclear.
These functions are obsolete: do not use them in new programs.
.SH NOTES
On 4.3BSD, the
.BR signal ()
function provided reliable semantics (as when calling
.BR sigvec ()
with
.I vec.sv_mask
equal to 0).
On System V,
.BR signal ()
provides unreliable semantics.
POSIX.1 leaves these aspects of
.BR signal ()
unspecified.
See
.BR signal (2)
for further details.
.PP
In order to wait for a signal,
BSD and System V both provided a function named
.BR sigpause (3),
but this function has a different argument on the two systems.
See
.BR sigpause (3)
for details.
.SH SEE ALSO
.BR kill (2),
.BR pause (2),
.BR sigaction (2),
.BR signal (2),
.BR sigprocmask (2),
.BR raise (3),
.BR sigpause (3),
.BR sigset (3),
.BR signal (7)