setjmp()

NAME

setjmp(), longjmp(), sigsetjmp(), siglongjmp() - non-local jumps

SYNOPSIS

#include <setjmp.h>

int setjmp (jmp_buf env) void longjmp (jmp_buf env, int val) int sigsetjmp (sigjmp_buf env, int savemask) void siglongjmp (sigjmp_buf env, int val)

DESCRIPTION

The setjmp(3) and sigsetjmp(3) functions save their calling environment in env. Each of these functions returns 0.

The corresponding longjmp(3) functions restore the environment saved by their most recent respective invocations of the setjmp(3) function. They then return so that program execution continues as if the corresponding invocation of the setjmp(3) call had just returned the value specified by val, instead of 0.

Sigsetjmp(3) and siglongjmp(3) save and restore the signal mask if the argument savemask is non-zero; otherwise they behave identically with setjmp(3) and longjmp(3).

The longjmp(3) routines may not be called after the routine which called the setjmp(3) routines returns.

All accessible objects have values as of the time longjmp(3) 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(3) invocation and longjmp(3) call are indeterminate.

Pairs of calls may be intermixed, i.e. both sigsetjmp(3) and siglongjmp(3) and setjmp(3) and longjmp(3) combinations may be used in the same program, however, individual calls may not, e.g. the env argument to setjmp(3) may not be passed to siglongjmp(3).

RETURN VALUES

When invoked directly, setjmp(3) returns zero; when invoked as part of longjmp(3), setjmp(3) returns non-zero.

When invoked directly, sigsetjmp(3) returns zero; when invoked as part of siglongjmp(3), sigsetjmp(3) returns non-zero.

SEE ALSO

sigaction(2)

signal(2)