The
sigsetjmp(),
setjmp(), and
_setjmp() functions save their calling environment in
env. Each of these functions returns 0.
The corresponding
longjmp() functions restore the environment saved by the most recent invocation of the respective
setjmp() function. They then return so that program execution continues as if the corresponding invocation of the
setjmp() call had just returned the value specified by
val, instead of 0.
Pairs of calls may be intermixed, i.e., both
sigsetjmp() and
siglongjmp() as well as
setjmp() and
longjmp() combinations may be used in the same program. However, individual calls may not, e.g., the
env argument to
setjmp() may not be passed to
siglongjmp().
The
longjmp() routines may not be called after the routine which called the
setjmp() routines returns.
All accessible objects have values as of the time
longjmp() routine was called, except that the values of objects of automatic storage invocation duration that do not have the
volatile type and have been changed between the
setjmp() invocation and
longjmp() call are indeterminate.
The
setjmp()/
longjmp() function pairs save and restore the signal mask while
_setjmp()/
_longjmp() function pairs save and restore only the register set and the stack. (See
sigprocmask(
2).)
The
sigsetjmp()/
siglongjmp() function pairs save and restore the signal mask if the argument
savemask is non-zero. Otherwise, only the register set and the stack are saved.
In other words,
setjmp()/
longjmp() are functionally equivalent to
sigsetjmp()/
siglongjmp() when
sigsetjmp() is called with a non-zero
savemask argument. Conversely,
_setjmp()/
_longjmp() are functionally equivalent to
sigsetjmp()/
siglongjmp() when
sigsetjmp() is called with a zero-value
savemask.
The
sigsetjmp()/
siglongjmp() interfaces are preferred for maximum portability.