1SIGSUSPEND(3P)             POSIX Programmer's Manual            SIGSUSPEND(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       sigsuspend — wait for a signal
13

SYNOPSIS

15       #include <signal.h>
16
17       int sigsuspend(const sigset_t *sigmask);
18

DESCRIPTION

20       The sigsuspend() function shall replace the current signal mask of  the
21       calling  thread  with the set of signals pointed to by sigmask and then
22       suspend the thread until delivery of a signal whose action is either to
23       execute  a  signal-catching  function or to terminate the process. This
24       shall not cause any other signals that may have  been  pending  on  the
25       process to become pending on the thread.
26
27       If the action is to terminate the process then sigsuspend() shall never
28       return. If the action is to execute a  signal-catching  function,  then
29       sigsuspend()  shall  return after the signal-catching function returns,
30       with the signal mask restored to the set that existed prior to the sig‐
31       suspend() call.
32
33       It  is  not  possible  to block signals that cannot be ignored. This is
34       enforced by the system without causing an error to be indicated.
35

RETURN VALUE

37       Since sigsuspend() suspends thread execution indefinitely, there is  no
38       successful  completion  return  value.  If a return occurs, -1 shall be
39       returned and errno set to indicate the error.
40

ERRORS

42       The sigsuspend() function shall fail if:
43
44       EINTR  A signal is  caught  by  the  calling  process  and  control  is
45              returned from the signal-catching function.
46
47       The following sections are informative.
48

EXAMPLES

50       None.
51

APPLICATION USAGE

53       Normally,  at the beginning of a critical code section, a specified set
54       of signals is blocked using the sigprocmask() function. When the thread
55       has completed the critical section and needs to wait for the previously
56       blocked signal(s), it pauses by calling sigsuspend() with the mask that
57       was returned by the sigprocmask() call.
58

RATIONALE

60       Code  which  wants to avoid the ambiguity of the signal mask for thread
61       cancellation handlers can install an  additional  cancellation  handler
62       which resets the signal mask to the expected value.
63
64
65           void cleanup(void *arg)
66           {
67               sigset_t *ss = (sigset_t *) arg;
68               pthread_sigmask(SIG_SETMASK, ss, NULL);
69           }
70
71           int call_sigsuspend(const sigset_t *mask)
72           {
73               sigset_t oldmask;
74               int result;
75               pthread_sigmask(SIG_SETMASK, NULL, &oldmask);
76               pthread_cleanup_push(cleanup, &oldmask);
77               result = sigsuspend(sigmask);
78               pthread_cleanup_pop(0);
79               return result;
80           }
81

FUTURE DIRECTIONS

83       None.
84

SEE ALSO

86       Section   2.4,  Signal  Concepts,  pause(),  sigaction(),  sigaddset(),
87       sigdelset(), sigemptyset(), sigfillset()
88
89       The Base Definitions volume of POSIX.1‐2017, <signal.h>
90
92       Portions of this text are reprinted and reproduced in  electronic  form
93       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
94       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
95       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
96       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
97       event of any discrepancy between this version and the original IEEE and
98       The Open Group Standard, the original IEEE and The Open Group  Standard
99       is  the  referee document. The original Standard can be obtained online
100       at http://www.opengroup.org/unix/online.html .
101
102       Any typographical or formatting errors that appear  in  this  page  are
103       most likely to have been introduced during the conversion of the source
104       files to man page format. To report such errors,  see  https://www.ker
105       nel.org/doc/man-pages/reporting_bugs.html .
106
107
108
109IEEE/The Open Group                  2017                       SIGSUSPEND(3P)
Impressum