SIGSETJMP(3POSIX)
πΈ SIGSETJMP(3POSIX) β the POSIX Programmer's Manual, bestie edition πΈ
okay so before we even get into it, quick heads up about the POSIX Programmer's Manual itself π
π PROLOG π
This page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so like, go check the corresponding Linux manual page for the deets on how Linux actually does it β or honestly the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
sigsetjmp β set jump point for a non-local goto
π SYNOPSIS π
#include <setjmp.h>
int sigsetjmp(sigjmp_buf env, int savemask);
π DESCRIPTION π
So sigsetjmp() is literally just setjmp(), bestie, except for these lil differences:
- Any references to
setjmp()are equivalent tosigsetjmp(). π - Any references to
longjmp()are equivalent tosiglongjmp(). π - If the value of the
savemaskargument is not0, thensigsetjmp()shall also save the current signal mask of the calling thread as part of the calling environment. π (like it's packing an extra lil snack in your bag, no big deal)
π¦ RETURN VALUE π¦
If the return comes from a successful direct invocation, sigsetjmp() shall return 0. β¨
If the return comes from a call to siglongjmp(), sigsetjmp() shall return a non-zero value. π
π ERRORS π
No errors are defined. iconic, nothing to worry about π
The following sections are informative.
π EXAMPLES π
None. (not a single one. the silence is deafening π)
π«Ά APPLICATION USAGE π«Ά
The distinction between setjmp()/longjmp() and sigsetjmp()/siglongjmp() is only significant for programs which use sigaction(), sigprocmask(), or sigsuspend(). iykyk π§
Also note that since this function is defined in terms of setjmp(), if savemask is zero, it is unspecified whether the signal mask is saved. so likeβ¦ don't count on it, bestie π
π RATIONALE π
The ISO C standard specifies various restrictions on the usage of the setjmp() macro, and the whole reason is so implementors can recognize the name in the compiler and not implement an actual function. Those same restrictions apply to the sigsetjmp() macro. periodt. π
There are processors that cannot easily support these calls β but that was not considered a sufficient reason to exclude them. they said no girl left behind π
Okay so history lesson time, because this part is juicy:
4.2 BSD, 4.3 BSD, and XSI-conformant systems provide functions named _setjmp() and _longjmp() that, together with setjmp() and longjmp(), provide the same functionality as sigsetjmp() and siglongjmp(). On those systems, setjmp() and longjmp() save and restore signal masks, while _setjmp() and _longjmp() do not.
On System V Release 3 and in corresponding issues of the SVID, setjmp() and longjmp() are explicitly defined not to save and restore signal masks. π±
So to permit existing practice in both cases, the relation of setjmp() and longjmp() to signal masks is not specified, and a whole new set of functions is defined instead. slay, honestly.
The longjmp() and siglongjmp() functions operate as in the previous issue β provided the matching setjmp() or sigsetjmp() has been performed in the same thread. Non-local jumps into contexts saved by other threads would be, at best, a questionable practice, and were not considered worthy of standardization. likeβ¦ ma'am, don't do that. π©
β FUTURE DIRECTIONS β
None. (the future is bright and empty, bestie β¨)
π₯ SEE ALSO π₯
pthread_sigmask()siglongjmp()signal()sigsuspend()
Also! The Base Definitions volume of POSIX.1β2017, <setjmp.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 .
ok that's the whole page, no cap π«Ά
and that's a wrap, bestie β this lil masterpiece came to you courtesy of IEEE/The Open Group, dated 2017, and it's the SIGSETJMP(3POSIX) page itself. go forth and non-local-goto 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