scripts/bash_aliases: tfix
[man-pages.git] / man2 / sigsuspend.2
blob65041f3865adadf1740a7b07a0733ad10be70f3f
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 2021-03-22 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 sigsuspend, rt_sigsuspend \- wait for a signal
32 .SH SYNOPSIS
33 .nf
34 .B #include <signal.h>
35 .PP
36 .BI "int sigsuspend(const sigset_t *" mask );
37 .fi
38 .PP
39 .RS -4
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
42 .RE
43 .PP
44 .BR sigsuspend ():
45 .nf
46     _POSIX_C_SOURCE
47 .fi
48 .SH DESCRIPTION
49 .BR sigsuspend ()
50 temporarily replaces the signal mask of the calling thread with the
51 mask given by
52 .I mask
53 and then suspends the thread until delivery of a signal whose
54 action is to invoke a signal handler or to terminate a process.
55 .PP
56 If the signal terminates the process, then
57 .BR sigsuspend ()
58 does not return.
59 If the signal is caught, then
60 .BR sigsuspend ()
61 returns after the signal handler returns,
62 and the signal mask is restored to the state before the call to
63 .BR sigsuspend ().
64 .PP
65 It is not possible to block
66 .B SIGKILL
68 .BR SIGSTOP ;
69 specifying these signals in
70 .IR mask ,
71 has no effect on the thread's signal mask.
72 .SH RETURN VALUE
73 .BR sigsuspend ()
74 always returns \-1, with
75 .I errno
76 set to indicate the error (normally,
77 .BR EINTR ).
78 .SH ERRORS
79 .TP
80 .B EFAULT
81 .I mask
82 points to memory which is not a valid part of the process address space.
83 .TP
84 .B EINTR
85 The call was interrupted by a signal;
86 .BR signal (7).
87 .SH CONFORMING TO
88 POSIX.1-2001, POSIX.1-2008.
89 .SH NOTES
90 Normally,
91 .BR sigsuspend ()
92 is used in conjunction with
93 .BR sigprocmask (2)
94 in order to prevent delivery of a signal during the execution of a
95 critical code section.
96 The caller first blocks the signals with
97 .BR sigprocmask (2).
98 When the critical code has completed, the caller then waits for the
99 signals by calling
100 .BR sigsuspend ()
101 with the signal mask that was returned by
102 .BR sigprocmask (2)
103 (in the
104 .I oldset
105 argument).
108 .BR sigsetops (3)
109 for details on manipulating signal sets.
111 .SS C library/kernel differences
112 The original Linux system call was named
113 .BR sigsuspend ().
114 However, with the addition of real-time signals in Linux 2.2,
115 the fixed-size, 32-bit
116 .IR sigset_t
117 type supported by that system call was no longer fit for purpose.
118 Consequently, a new system call,
119 .BR rt_sigsuspend (),
120 was added to support an enlarged
121 .IR sigset_t
122 type.
123 The new system call takes a second argument,
124 .IR "size_t sigsetsize" ,
125 which specifies the size in bytes of the signal set in
126 .IR mask .
127 This argument is currently required to have the value
128 .IR sizeof(sigset_t)
129 (or the error
130 .B EINVAL
131 results).
132 The glibc
133 .BR sigsuspend ()
134 wrapper function hides these details from us, transparently calling
135 .BR rt_sigsuspend ()
136 when the kernel provides it.
138 .SH SEE ALSO
139 .BR kill (2),
140 .BR pause (2),
141 .BR sigaction (2),
142 .BR signal (2),
143 .BR sigprocmask (2),
144 .BR sigwaitinfo (2),
145 .BR sigsetops (3),
146 .BR sigwait (3),
147 .BR signal (7)