xref: /original-bsd/lib/libc/gen/setjmp.3 (revision 502feadc)
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

%sccs.include.redist.man%

@(#)setjmp.3 6.4 (Berkeley) 05/27/90

SETJMP 3 ""
C 4
NAME
sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp longjmperror - non-local jumps
SYNOPSIS
#include <setjmp.h>

sigsetjmp(sigjmp_buf env, int savemask);

void
siglongjmp(sigjmp_buf env, int val);

setjmp(jmp_buf env);

void
longjmp(jmp_buf env, int val);

_setjmp(jmp_buf env);

void
_longjmp(jmp_buf env, int val);

void
longjmperror();
DESCRIPTION
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 their respective versions of the setjmp function. They then return so that program execution continues as if the setjmp call had returned val , instead of 0.

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

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

All accessible data have values as of the time the longjmp routine was called.

Setjmp/longjmp pairs save and restore the signal mask (see sigmask (2)), while _setjmp/_longjmp pairs save and restore only the register set and the stack.

Sigsetjmp/siglongjmp pairs save and restore the signal mask if the argument savemask is non-zero, otherwise only the register set and the stack are saved.

ERRORS
If the contents of the env are corrupted, or correspond to an environment that has already returned, the longjmp routine calls the routine longjmperror (3). If longjmperror returns the program is aborted (see abort(2)). The default version of longjmperror prints the message ``longjmp botch'' to standard error and returns. User programs wishing to exit more gracefully should write their own versions of longjmperror .
"SEE ALSO"
sigvec(2), sigstack(2), signal(3)