]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/sigsuspend.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / sigsuspend.2
1 .\" Copyright (c) 2005 Michael Kerrisk
2 .\" based on earlier work by faith@cs.unc.edu and
3 .\" Mike Battersby <mib@deakin.edu.au>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
28 .\"
29 .TH SIGSUSPEND 2 2019-03-06 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 sigsuspend, rt_sigsuspend \- wait for a signal
32 .SH SYNOPSIS
33 .B #include <signal.h>
34 .PP
35 .BI "int sigsuspend(const sigset_t *" mask );
36 .PP
37 .in -4n
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .in
41 .PP
42 .ad l
43 .BR sigsuspend ():
44 _POSIX_C_SOURCE
45 .ad b
46 .SH DESCRIPTION
47 .BR sigsuspend ()
48 temporarily replaces the signal mask of the calling thread with the
49 mask given by
50 .I mask
51 and then suspends the thread until delivery of a signal whose
52 action is to invoke a signal handler or to terminate a process.
53 .PP
54 If the signal terminates the process, then
55 .BR sigsuspend ()
56 does not return.
57 If the signal is caught, then
58 .BR sigsuspend ()
59 returns after the signal handler returns,
60 and the signal mask is restored to the state before the call to
61 .BR sigsuspend ().
62 .PP
63 It is not possible to block
64 .B SIGKILL
65 or
66 .BR SIGSTOP ;
67 specifying these signals in
68 .IR mask ,
69 has no effect on the thread's signal mask.
70 .SH RETURN VALUE
71 .BR sigsuspend ()
72 always returns \-1, with
73 .I errno
74 set to indicate the error (normally,
75 .BR EINTR ).
76 .SH ERRORS
77 .TP
78 .B EFAULT
79 .I mask
80 points to memory which is not a valid part of the process address space.
81 .TP
82 .B EINTR
83 The call was interrupted by a signal;
84 .BR signal (7).
85 .SH CONFORMING TO
86 POSIX.1-2001, POSIX.1-2008.
87 .SH NOTES
88 .PP
89 Normally,
90 .BR sigsuspend ()
91 is used in conjunction with
92 .BR sigprocmask (2)
93 in order to prevent delivery of a signal during the execution of a
94 critical code section.
95 The caller first blocks the signals with
96 .BR sigprocmask (2).
97 When the critical code has completed, the caller then waits for the
98 signals by calling
99 .BR sigsuspend ()
100 with the signal mask that was returned by
101 .BR sigprocmask (2)
102 (in the
103 .I oldset
104 argument).
105 .PP
106 See
107 .BR sigsetops (3)
108 for details on manipulating signal sets.
109 .\"
110 .SS C library/kernel differences
111 The original Linux system call was named
112 .BR sigsuspend ().
113 However, with the addition of real-time signals in Linux 2.2,
114 the fixed-size, 32-bit
115 .IR sigset_t
116 type supported by that system call was no longer fit for purpose.
117 Consequently, a new system call,
118 .BR rt_sigsuspend (),
119 was added to support an enlarged
120 .IR sigset_t
121 type.
122 The new system call takes a second argument,
123 .IR "size_t sigsetsize" ,
124 which specifies the size in bytes of the signal set in
125 .IR mask .
126 This argument is currently required to have the value
127 .IR sizeof(sigset_t)
128 (or the error
129 .B EINVAL
130 results).
131 The glibc
132 .BR sigsuspend ()
133 wrapper function hides these details from us, transparently calling
134 .BR rt_sigsuspend ()
135 when the kernel provides it.
136 .\"
137 .SH SEE ALSO
138 .BR kill (2),
139 .BR pause (2),
140 .BR sigaction (2),
141 .BR signal (2),
142 .BR sigprocmask (2),
143 .BR sigwaitinfo (2),
144 .BR sigsetops (3),
145 .BR sigwait (3),
146 .BR signal (7)