SIGHOLD(3POSIX)
π SIGHOLD(3POSIX) β the POSIX Programmer's Manual, but make it make sense π
okay bestie, welcome to SIGHOLD(3POSIX) from the POSIX Programmer's Manual β¨ this is the girlies' guide to the old-school signal management squad and yes, we're gonna get through all of it together, no cap π«Ά
πΈ PROLOG πΈ
okay so real talk first, this is important:
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
so likeβ¦ don't come for me if Linux does its own thing, that's literally what the page says π
β¨ NAME β¨
sighold, sigignore, sigpause, sigrelse, sigset β signal management
it's giving "the whole girl group, five members, one job" π
π SYNOPSIS π
#include <signal.h>
int sighold(int sig);
int sigignore(int sig);
int sigpause(int sig);
int sigrelse(int sig);
void (*sigset(int sig, void (*disp)(int)))(int);
yes that last one is a function returning a function pointer, she's highkey iconic and also a little scary, we love her π
π¦ DESCRIPTION π¦
okay first things first, the disclaimer:
Use of any of these functions is unspecified in a multi-threaded process.
so like, single-threaded girlies only for this whole crew, periodt π
The sighold(), sigignore(), sigpause(), sigrelse(), and sigset() functions provide simplified signal management. simplified! because sometimes you don't wanna do the whole big thing π§
sigset() β the main character π
The sigset() function shall modify signal dispositions.
- The
sigargument specifies the signal, which may be any signal exceptSIGKILLandSIGSTOP. - The
dispargument specifies the signal's disposition, which may beSIG_DFL,SIG_IGN, or the address of a signal handler.
now here's the tea, three separate scenarios:
- If
sigset()is used, anddispis the address of a signal handler, the system shall addsigto the signal mask of the calling process before executing the signal handler; when the signal handler returns, the system shall restore the signal mask of the calling process to its state prior to the delivery of the signal. so she blocks herself while she's handling business, very self-aware π - In addition, if
sigset()is used, anddispis equal toSIG_HOLD,sigshall be added to the signal mask of the calling process andsig's disposition shall remain unchanged. - If
sigset()is used, anddispis not equal toSIG_HOLD,sigshall be removed from the signal mask of the calling process.
the rest of the squad π
- The
sighold()function shall addsigto the signal mask of the calling process. - The
sigrelse()function shall removesigfrom the signal mask of the calling process. - The
sigignore()function shall set the disposition ofsigtoSIG_IGN. - The
sigpause()function shall removesigfrom the signal mask of the calling process and suspend the calling process until a signal is received. Thesigpause()function shall restore the signal mask of the process to its original state before returning.
the SIGCHLD situation π
this one's a whole plot twist, pay attention:
If the action for the SIGCHLD signal is set to SIG_IGN, child processes of the calling processes shall not be transformed into zombie processes when they terminate.
If the calling process subsequently waits for its children, and the process has no unwaited-for children that were transformed into zombie processes, it shall block until all of its children terminate, and wait(), waitid(), and waitpid() shall fail and set errno to [ECHILD].
no zombies but also no chill, the tradeoff is real π
π RETURN VALUE π
okay so what do you get back:
- Upon successful completion,
sigset()shall returnSIG_HOLDif the signal had been blocked, and the signal's previous disposition if it had not been blocked. Otherwise,SIG_ERRshall be returned anderrnoset to indicate the error. - The
sigpause()function shall suspend execution of the thread until a signal is received, whereupon it shall return-1and seterrnoto[EINTR]. - For all other functions, upon successful completion,
0shall be returned. Otherwise,-1shall be returned anderrnoset to indicate the error.
so: two functions with β¨personalityβ¨ and the rest being basic 0/-1 girlies π
π₯ ERRORS π₯
These functions shall fail if:
EINVALβ Thesigargument is an illegal signal number.
The sigset() and sigignore() functions shall fail if:
EINVALβ An attempt is made to catch a signal that cannot be caught, or to ignore a signal that cannot be ignored.
two different EINVAL flavors, same name, different drama π
The following sections are informative.
π EXAMPLES π
None.
literally none, the well is dry bestie, moving on π«Ά
π APPLICATION USAGE π
- The
sigaction()function provides a more comprehensive and reliable mechanism for controlling signals; new applications should use thesigaction()function instead of the obsolescentsigset()function. - The
sighold()function, in conjunction withsigrelse()orsigpause(), may be used to establish critical regions of code that require the delivery of a signal to be temporarily deferred. For broader portability, thepthread_sigmask()orsigprocmask()functions should be used instead of the obsolescentsighold()andsigrelse()functions. - For broader portability, the
sigsuspend()function should be used instead of the obsolescentsigpause()function.
π¨ bestie listen: the word obsolescent is doing a lot of heavy lifting in this section. these are the legacy girlies. new code, new functions. periodt.
π RATIONALE π
Each of these historic functions has a direct analog in the other functions which are required to be per-thread and thread-safe (aside from sigprocmask(), which is replaced by pthread_sigmask()).
and here's the translation table, no cap:
- The
sigset()function can be implemented as a simple wrapper forsigaction(). - The
sighold()function is equivalent tosigprocmask()orpthread_sigmask()withSIG_BLOCKset. - The
sigignore()function is equivalent tosigaction()withSIG_IGNset. - The
sigpause()function is equivalent tosigsuspend(). - The
sigrelse()function is equivalent tosigprocmask()orpthread_sigmask()withSIG_UNBLOCKset.
so basically the whole crew is a cover band for the modern functions, and honestly? respect π€
π¦ FUTURE DIRECTIONS π¦
These functions may be removed in a future version.
π they said "may be removed" which is the manual-page equivalent of "we need to talk"
π SEE ALSO π
- Section 2.4, Signal Concepts
execpause()pthread_sigmask()sigaction()signal()sigsuspend()wait()waitid()- The Base Definitions volume of POSIX.1β2017,
<signal.h>
go read those, they're the glow-up versions of everything above πΈ
π 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 .
okay that's the whole page bestie, and a lil sign-off for you: this one came from IEEE/The Open Group, dated 2017, filed under SIGHOLD(3POSIX) π you understood all of that and honestly? slay. go forth and block your 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