Blame man3/sigvec.3

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