sigsetjmp(3C) sigsetjmp(3C)
NAME
sigsetjmp, siglongjmp - a non-local goto with signal state
SYNOPSIS
#include <setjmp.h>
int sigsetjmp(sigjmpbuf env, int savemask);
void siglongjmp(sigjmpbuf env, int val);
DESCRIPTION
Using these functions, errors and interrupts encountered in a low-
level subroutine of a program can be handled.
sigsetjmp() saves the calling process' registers and stack environment
[see sigaltstack(2)] in env (whose type, sigjmpbuf, is defined in the
setjmp.h header file) for later use by siglongjmp(). If savemask is
non-zero, the calling process' signal mask [see sigprocmask(2)] and
scheduling parameters [see priocntl(2)] are also saved. sigsetjmp()
returns the value 0.
siglongjmp() restores the environment saved by the last call of
sigsetjmp() with the corresponding env argument. After siglongjmp() is
completed, program execution continues as if the corresponding call of
sigsetjmp() had just returned the value val. siglongjmp() cannot cause
sigsetjmp() to return the value zero. If siglongjmp() is invoked with
a second argument of zero, sigsetjmp() will return 1. At the time of
the second return from sigsetjmp(), all external and static variables
have values as of the time siglongjmp() is called. The values of
register and auto variables are undefined. Register or auto variables
whose value must be relied upon must be declared as volatile.
All accessible objects have values as of the time siglongjmp() was
called, except that the values of objects of automatic storage dura-
tion which are local to the function containing the invocation of the
corresponding sigsetjmp() which do not have volatile-qualified type
and which are changed between the sigsetjmp() invocation and
siglongjmp() call are indeterminate.
An invocation of sigsetjmp() must appear in one of the following con-
texts only:
- the entire controlling expression of a selection or iteration
statement
- one operand of a relational or equality operator with the other
operand an integral constant expression, with the resulting expres-
sion being the entire controlling expression of a selection or
iteration statement
Page 1 Reliant UNIX 5.44 Printed 11/98
sigsetjmp(3C) sigsetjmp(3C)
- the operand of a unary operator with the resulting expression being
the entire controlling expression of a selection or iteration
statement
- the entire expression of an expression statement (possibly cast to
void)
If a signal-catching function interrupts sleep() and calls
siglongjmp() to restore an environment saved prior to the sleep()
call, the action associated with SIGALRM and time it is scheduled to
be generated are unspecified. It is also unspecified whether the
SIGALRM signal is blocked, unless the process' signal mask is restored
as part of the environment.
The function siglongjmp() restores the saved signal mask if and only
if the env argument was initialized by a call to the sigsetjmp() func-
tion with a non-zero savemask argument.
NOTES
If siglongjmp() is called even though env was never primed by a call
to sigsetjmp(), or when the last such call was in a function that has
since returned, absolute chaos is guaranteed.
SEE ALSO
getcontext(2), priocntl(2), sigaction(2), sigaltstack(2),
sigprocmask(2), setjmp(3C).
Page 2 Reliant UNIX 5.44 Printed 11/98