]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sigvec.3
sigvec.3: Fix small error in discussion of blocking of signals
[thirdparty/man-pages.git] / man3 / sigvec.3
CommitLineData
9c2866d7 1'\" t
c11b1abf 2.\" Copyright (c) 2005 by Michael Kerrisk <mtk.manpages@gmail.com>
9c2866d7
MK
3.\"
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
9c2866d7
MK
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\"
e191c685 24.TH SIGVEC 3 2012-09-06 "Linux" "Linux Programmer's Manual"
9c2866d7
MK
25.SH NAME
26sigvec, sigblock, sigsetmask, siggetmask, sigmask \- BSD signal API
27.SH SYNOPSIS
9c2866d7
MK
28.B #include <signal.h>
29.sp
30.BI "int sigvec(int " sig ", struct sigvec *" vec ", struct sigvec *" ovec );
31.sp
32.BI "int sigmask(int " signum );
33.sp
34.BI "int sigblock(int " mask );
35.sp
36.BI "int sigsetmask(int " mask );
37.sp
38.B int siggetmask(void);
cc4615cc
MK
39.sp
40.in -4n
41Feature Test Macro Requirements for glibc (see
42.BR feature_test_macros (7)):
43.in
44.sp
cfc2d88d 45All functions shown above:
cc4615cc 46_BSD_SOURCE
9c2866d7
MK
47.SH DESCRIPTION
48These functions are provided in glibc as a compatibility interface
49for programs that make use of the historical BSD signal API.
c13182ef
MK
50This API is obsolete: new applications should use the POSIX signal API
51.RB ( sigaction (2),
9c2866d7 52.BR sigprocmask (2),
1bea464c 53etc.).
9c2866d7
MK
54
55The
56.BR sigvec ()
57function sets and/or gets the disposition of the signal
c13182ef 58.I sig
9c2866d7
MK
59(like the POSIX
60.BR sigaction (2)).
c13182ef 61If
9c2866d7
MK
62.I vec
63is not NULL, it points to a
64.I sigvec
c13182ef 65structure that defines the new disposition for
9c2866d7
MK
66.IR sig .
67If
68.I ovec
c13182ef 69is not NULL, it points to a
9c2866d7
MK
70.I sigvec
71structure that is used to return the previous disposition of
72.IR sig .
c13182ef 73To obtain the current disposition of
9c2866d7
MK
74.I sig
75without changing it, specify NULL for
c13182ef 76.IR vec ,
9c2866d7
MK
77and a non-NULL pointer for
78.IR ovec .
79
80The dispositions for
81.B SIGKILL
c13182ef 82and
9c2866d7
MK
83.B SIGSTOP
84cannot be changed.
85
86The
87.I sigvec
88structure has the following form:
088a639b 89.in +4n
9c2866d7
MK
90.nf
91
92struct sigvec {
93 void (*sv_handler)(); /* Signal disposition */
94 int sv_mask; /* Signals to be blocked in handler */
95 int sv_flags; /* Flags */
96};
97
98.fi
d4f3dcff 99.in
9c2866d7
MK
100The
101.I sv_handler
102field specifies the disposition of the signal, and is either:
1bea464c
MK
103the address of a signal handler function;
104.BR SIG_DFL ,
9c2866d7 105meaning the default disposition applies for the signal; or
1bea464c 106.BR SIG_IGN ,
9c2866d7
MK
107meaning that the signal is ignored.
108
109If
110.I sv_handler
111specifies the address of a signal handler, then
112.I sv_mask
c13182ef 113specifies a mask of signals that are to be blocked while
9c2866d7 114the handler is executing.
c13182ef 115In addition, the signal for which the handler is invoked is
e191c685 116also blocked.
9c2866d7
MK
117Attempts to block
118.B SIGKILL
c13182ef 119or
9c2866d7
MK
120.B SIGSTOP
121are silently ignored.
122
123If
124.I sv_handler
125specifies the address of a signal handler, then the
126.I sv_flags
127field specifies flags controlling what happens when the handler is called.
128This field may contain zero or more of the following flags:
129.TP
130.B SV_INTERRUPT
131If the signal handler interrupts a blocking system call,
132then upon return from the handler the system call will not be restarted:
133instead it will fail with the error
7b2b5ea4 134.BR EINTR .
c13182ef 135If this flag is not specified, then system calls are restarted
9c2866d7
MK
136by default.
137.TP
138.B SV_RESETHAND
c13182ef 139Reset the disposition of the signal to the default
9c2866d7
MK
140before calling the signal handler.
141If this flag is not specified, then the handler remains established
c13182ef 142until explicitly removed by a later call to
9c2866d7
MK
143.BR sigvec ()
144or until the process performs an
145.BR execve (2).
146.TP
147.B SV_ONSTACK
c13182ef
MK
148Handle the signal on the alternate signal stack
149(historically established under BSD using the obsolete
9c2866d7 150.BR sigstack ()
c13182ef 151function; the POSIX replacement is
fb186734 152.BR sigaltstack (2)).
9c2866d7 153.PP
c13182ef 154The
9c2866d7
MK
155.BR sigmask ()
156function constructs and returns a "signal mask" for
157.IR signum .
d9bfdb9c 158For example, we can initialize the
c13182ef
MK
159.I vec.sv_mask
160field given to
9c2866d7
MK
161.BR sigvec ()
162using code such as the following:
163.nf
164
cf0a9ace 165 vec.sv_mask = sigmask(SIGQUIT) | sigpause(SIGABRT);
c13182ef 166 /* Block SIGQUIT and SIGABRT during
9c2866d7
MK
167 handler execution */
168.fi
169.PP
170The
171.BR sigblock ()
172function adds the signals in
173.I mask
174to the process's signal mask
c13182ef 175(like POSIX
9c2866d7
MK
176.IR sigprocmask(SIG_BLOCK) ),
177and returns the process's previous signal mask.
178Attempts to block
179.B SIGKILL
c13182ef 180or
9c2866d7
MK
181.B SIGSTOP
182are silently ignored.
183.PP
c13182ef 184The
9c2866d7
MK
185.BR sigsetmask ()
186function sets the process's signal mask to the value given in
c13182ef
MK
187.I mask
188(like POSIX
9c2866d7
MK
189.IR sigprocmask(SIG_SETMASK) ),
190and returns the process's previous signal mask.
191.PP
192The
193.BR siggetmask ()
194function returns the process's current signal mask.
195This call is equivalent to
196.IR sigblock(0) .
197.SH RETURN VALUE
c13182ef 198The
9c2866d7
MK
199.BR sigvec ()
200function returns 0 on success; on error, it returns \-1 and sets
c13182ef 201.I errno
9c2866d7
MK
202to indicate the error.
203
204The
205.BR sigblock ()
206and
207.BR sigsetmask ()
208functions return the previous signal mask.
209
210The
211.BR sigmask ()
212function returns the signal mask for
213.IR signum .
214.SH ERRORS
215See the ERRORS under
216.BR sigaction (2)
217and
218.BR sigprocmask (2).
2b2581ee
MK
219.SH "CONFORMING TO"
220All of these functions were in
2214.3BSD, except
222.BR siggetmask (),
223whose origin is unclear.
224These functions are obsolete: do not use them in new programs.
9c2866d7
MK
225.SH NOTES
226On 4.3BSD, the
227.BR signal ()
c13182ef 228function provided reliable semantics (as when calling
9c2866d7
MK
229.BR sigvec ()
230with
231.I vec.sv_mask
232equal to 0).
233On System V,
234.BR signal ()
235provides unreliable semantics.
c13182ef 236POSIX.1-2001 leaves these aspects of
9c2866d7
MK
237.BR signal ()
238unspecified.
c13182ef 239See
9c2866d7
MK
240.BR signal (2)
241for further details.
242
243In order to wait for a signal,
244BSD and System V both provided a function named
7a056410 245.BR sigpause (3),
9c2866d7
MK
246but this function has a different argument on the two systems.
247See
248.BR sigpause (3)
249for details.
9c2866d7
MK
250.SH "SEE ALSO"
251.BR kill (2),
252.BR pause (2),
9c2866d7
MK
253.BR sigaction (2),
254.BR signal (2),
255.BR sigprocmask (2),
9fe51d8d 256.BR raise (3),
46c721e7
MK
257.BR sigpause (3),
258.BR sigset (3),
9c2866d7 259.BR signal (7)