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
11

NAME

13       sigsuspend — wait for a signal
14

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

51       None.
52

APPLICATION USAGE

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

RATIONALE

61       Code  which  wants to avoid the ambiguity of the signal mask for thread
62       cancellation handlers can install an  additional  cancellation  handler
63       which resets the signal mask to the expected value.
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‐2008, <signal.h>
90
92       Portions of this text are reprinted and reproduced in  electronic  form
93       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
94       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
95       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
96       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
97       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
98       event of any discrepancy between this version and the original IEEE and
99       The  Open Group Standard, the original IEEE and The Open Group Standard
100       is the referee document. The original Standard can be  obtained  online
101       at http://www.unix.org/online.html .
102
103       Any  typographical  or  formatting  errors that appear in this page are
104       most likely to have been introduced during the conversion of the source
105       files  to  man page format. To report such errors, see https://www.ker
106       nel.org/doc/man-pages/reporting_bugs.html .
107
108
109
110IEEE/The Open Group                  2013                       SIGSUSPEND(3P)
Impressum