man-pages/man3/sigvec.3.html
2021-03-31 01:06:50 +01:00

438 lines
9.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SIGVEC</TITLE>
</HEAD><BODY>
<H1>SIGVEC</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sigvec, sigblock, sigsetmask, siggetmask, sigmask - BSD signal API
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/signal.h">signal.h</A>&gt;</B>
<P>
<B>int sigvec(int </B><I>sig</I><B>, const struct sigvec *</B><I>vec</I><B>, struct sigvec *</B><I>ovec</I><B>);</B>
<P>
<B>int sigmask(int </B><I>signum</I><B>);</B>
<P>
<B>int sigblock(int </B><I>mask</I><B>);</B>
<P>
<B>int sigsetmask(int </B><I>mask</I><B>);</B>
<P>
<B>int siggetmask(void);</B>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
All functions shown above:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;glibc&nbsp;2.19:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Glibc&nbsp;2.19&nbsp;and&nbsp;earlier:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_BSD_SOURCE
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
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
(<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sigprocmask">sigprocmask</A></B>(2),
etc.).
<P>
The
<B>sigvec</B>()
function sets and/or gets the disposition of the signal
<I>sig</I>
(like the POSIX
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2)).
If
<I>vec</I>
is not NULL, it points to a
<I>sigvec</I>
structure that defines the new disposition for
<I>sig</I>.
If
<I>ovec</I>
is not NULL, it points to a
<I>sigvec</I>
structure that is used to return the previous disposition of
<I>sig</I>.
To obtain the current disposition of
<I>sig</I>
without changing it, specify NULL for
<I>vec</I>,
and a non-null pointer for
<I>ovec</I>.
<P>
The dispositions for
<B>SIGKILL</B>
and
<B>SIGSTOP</B>
cannot be changed.
<P>
The
<I>sigvec</I>
structure has the following form:
<P>
struct sigvec {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;(*sv_handler)(int);&nbsp;/*&nbsp;Signal&nbsp;disposition&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;sv_mask;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Signals&nbsp;to&nbsp;be&nbsp;blocked&nbsp;in&nbsp;handler&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;sv_flags;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Flags&nbsp;*/
};
<P>
The
<I>sv_handler</I>
field specifies the disposition of the signal, and is either:
the address of a signal handler function;
<B>SIG_DFL</B>,
meaning the default disposition applies for the signal; or
<B>SIG_IGN</B>,
meaning that the signal is ignored.
<P>
If
<I>sv_handler</I>
specifies the address of a signal handler, then
<I>sv_mask</I>
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</B>
or
<B>SIGSTOP</B>
are silently ignored.
<P>
If
<I>sv_handler</I>
specifies the address of a signal handler, then the
<I>sv_flags</I>
field specifies flags controlling what happens when the handler is called.
This field may contain zero or more of the following flags:
<DL COMPACT>
<DT id="1"><B>SV_INTERRUPT</B>
<DD>
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
<B>EINTR</B>.
If this flag is not specified, then system calls are restarted
by default.
<DT id="2"><B>SV_RESETHAND</B>
<DD>
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
<B>sigvec</B>()
or until the process performs an
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2).
<DT id="3"><B>SV_ONSTACK</B>
<DD>
Handle the signal on the alternate signal stack
(historically established under BSD using the obsolete
<B>sigstack</B>()
function; the POSIX replacement is
<B><A HREF="/cgi-bin/man/man2html?2+sigaltstack">sigaltstack</A></B>(2)).
</DL>
<P>
The
<B>sigmask</B>()
macro constructs and returns a &quot;signal mask&quot; for
<I>signum</I>.
For example, we can initialize the
<I>vec.sv_mask</I>
field given to
<B>sigvec</B>()
using code such as the following:
<P>
vec.sv_mask = sigmask(SIGQUIT) | sigmask(SIGABRT);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Block&nbsp;SIGQUIT&nbsp;and&nbsp;SIGABRT&nbsp;during
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handler&nbsp;execution&nbsp;*/
<P>
The
<B>sigblock</B>()
function adds the signals in
<I>mask</I>
to the process's signal mask
(like POSIX
<I>sigprocmask(SIG_BLOCK)</I>),
and returns the process's previous signal mask.
Attempts to block
<B>SIGKILL</B>
or
<B>SIGSTOP</B>
are silently ignored.
<P>
The
<B>sigsetmask</B>()
function sets the process's signal mask to the value given in
<I>mask</I>
(like POSIX
<I>sigprocmask(SIG_SETMASK)</I>),
and returns the process's previous signal mask.
<P>
The
<B>siggetmask</B>()
function returns the process's current signal mask.
This call is equivalent to
<I>sigblock(0)</I>.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The
<B>sigvec</B>()
function returns 0 on success; on error, it returns -1 and sets
<I>errno</I>
to indicate the error.
<P>
The
<B>sigblock</B>()
and
<B>sigsetmask</B>()
functions return the previous signal mask.
<P>
The
<B>sigmask</B>()
macro returns the signal mask for
<I>signum</I>.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
See the ERRORS under
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2)
and
<B><A HREF="/cgi-bin/man/man2html?2+sigprocmask">sigprocmask</A></B>(2).
<A NAME="lbAG">&nbsp;</A>
<H2>VERSIONS</H2>
Starting with version 2.21, the GNU C library no longer exports the
<B>sigvec</B>()
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.)
<A NAME="lbAH">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>sigvec</B>(),
<B>sigmask</B>(),
<B>sigblock</B>(),
<B>sigsetmask</B>(),
<B>siggetmask</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAI">&nbsp;</A>
<H2>CONFORMING TO</H2>
All of these functions were in
4.3BSD, except
<B>siggetmask</B>(),
whose origin is unclear.
These functions are obsolete: do not use them in new programs.
<A NAME="lbAJ">&nbsp;</A>
<H2>NOTES</H2>
On 4.3BSD, the
<B>signal</B>()
function provided reliable semantics (as when calling
<B>sigvec</B>()
with
<I>vec.sv_mask</I>
equal to 0).
On System V,
<B>signal</B>()
provides unreliable semantics.
POSIX.1 leaves these aspects of
<B>signal</B>()
unspecified.
See
<B><A HREF="/cgi-bin/man/man2html?2+signal">signal</A></B>(2)
for further details.
<P>
In order to wait for a signal,
BSD and System V both provided a function named
<B><A HREF="/cgi-bin/man/man2html?3+sigpause">sigpause</A></B>(3),
but this function has a different argument on the two systems.
See
<B><A HREF="/cgi-bin/man/man2html?3+sigpause">sigpause</A></B>(3)
for details.
<A NAME="lbAK">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+kill">kill</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+pause">pause</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+signal">signal</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sigprocmask">sigprocmask</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?3+raise">raise</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sigpause">sigpause</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sigset">sigset</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7)
<A NAME="lbAL">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="7"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="8"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="9"><A HREF="#lbAG">VERSIONS</A><DD>
<DT id="10"><A HREF="#lbAH">ATTRIBUTES</A><DD>
<DT id="11"><A HREF="#lbAI">CONFORMING TO</A><DD>
<DT id="12"><A HREF="#lbAJ">NOTES</A><DD>
<DT id="13"><A HREF="#lbAK">SEE ALSO</A><DD>
<DT id="14"><A HREF="#lbAL">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:56 GMT, March 31, 2021
</BODY>
</HTML>