SIGSUSPEND(3POSIX)
π SIGSUSPEND π
okay bestie, so this one is from the POSIX Programmer's Manual β like, the actual official standard, not just some Linux thing. Sit down, hydrate, let's go π«Ά
πΈ PROLOG πΈ
So this page lives inside the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ (like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not be implemented on Linux at all. π
β¨ NAME β¨
sigsuspend β wait for a signal π¦
π SYNOPSIS π
#include <signal.h>
int sigsuspend(const sigset_t *sigmask);
π DESCRIPTION π
okay so here's the vibe. The sigsuspend() function shall replace the current signal mask of the calling thread with the set of signals pointed to by sigmask, and then it shall suspend the thread until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. And no cap β this shall not cause any other signals that may have been pending on the process to become pending on the thread. π§
If the action is to terminate the process then sigsuspend() shall never return. Like, never ever. π If the action is to execute a signal-catching function, then sigsuspend() shall return after the signal-catching function returns, with the signal mask restored to the set that existed prior to the sigsuspend() call. Iconic behavior honestly.
It is not possible to block signals that cannot be ignored. This is enforced by the system without causing an error to be indicated. The system just does it, silently, no drama, no errno, periodt. β¨
π RETURN VALUE π
Since sigsuspend() suspends thread execution indefinitely, there is no successful completion return value. Like, it's not giving success. If a return occurs, -1 shall be returned and errno set to indicate the error.
π ERRORS π
The sigsuspend() function shall fail if:
EINTRβ A signal is caught by the calling process and control is returned from the signal-catching function.
The following sections are informative. (yes, literally, that's what it says, bestie, they're marking the vibe shift π)
π EXAMPLES π
None. That's it. That's the section. π«
π¦ APPLICATION USAGE π¦
Normally, at the beginning of a critical code section, a specified set of signals is blocked using the sigprocmask() function. Then when the thread has completed the critical section and needs to wait for the previously blocked signal(s), it pauses by calling sigsuspend() with the mask that was returned by the sigprocmask() call. It's giving "put the signals back how you found them, then nap" energy. π΄β¨
π RATIONALE π
Code which wants to avoid the ambiguity of the signal mask for thread cancellation handlers can install an additional cancellation handler which resets the signal mask to the expected value. Like so:
void cleanup(void *arg)
{
sigset_t *ss = (sigset_t *) arg;
pthread_sigmask(SIG_SETMASK, ss, NULL);
}
int call_sigsuspend(const sigset_t *mask)
{
sigset_t oldmask;
int result;
pthread_sigmask(SIG_SETMASK, NULL, &oldmask);
pthread_cleanup_push(cleanup, &oldmask);
result = sigsuspend(sigmask);
pthread_cleanup_pop(0);
return result;
}
no cap, this is the whole reason the function exists in a thread-cancellation world π§΅π
β FUTURE DIRECTIONS β
None. Nothing coming. The future is empty. π³οΈ
π₯ SEE ALSO π₯
- Section 2.4, Signal Concepts
pause()sigaction()sigaddset()sigdelset()sigemptyset()sigfillset()
The Base Definitions volume of POSIX.1β2017, <signal.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! πβ¨π this one came to you from IEEE/The Open Group, dated 2017, under the SIGSUSPEND(3POSIX) glow-up. mwah, go catch some signals responsibly π¦π
π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms