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 to sigsetjmp(). πŸ”
  • Any references to longjmp() are equivalent to siglongjmp(). πŸ”
  • If the value of the savemask argument is not 0, then sigsetjmp() 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> πŸ“š


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 πŸ’…πŸŽ€βœ¨