Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #37
Difficulty: Easy
The hard disk space dedicated for swapping out processes on a memory-constrained Unix system is called the 'swap channel'.
True or False?
Linux & Unix Commands - Search Man Pages

setjmp(3) [bsd man page]

SETJMP(3)						     Library Functions Manual							 SETJMP(3)

NAME
setjmp, longjmp - non-local goto SYNOPSIS
#include <setjmp.h> setjmp(env) jmp_buf env; longjmp(env, val) jmp_buf env; _setjmp(env) jmp_buf env; _longjmp(env, val) jmp_buf env; DESCRIPTION
These routines are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. Setjmp saves its stack environment in env for later use by longjmp. It returns value 0. Longjmp restores the environment saved by the last call of setjmp. It then returns in such a way that execution continues as if the call of setjmp had just returned the value val to the function that invoked setjmp, which must not itself have returned in the interim. All accessible data have values as of the time longjmp was called. Setjmp and longjmp save and restore the signal mask sigmask(2), while _setjmp and _longjmp manipulate only the C stack and registers. ERRORS
If the contents of the jmp_buf are corrupted, or correspond to an environment that has already returned, longjmp calls the routine longjm- perror. If longjmperror returns the program is aborted. The default version of longjmperror prints the message ``longjmp botch'' to stan- dard error and returns. User programs wishing to exit more gracefully can write their own versions of longjmperror. SEE ALSO
sigvec(2), sigstack(2), signal(3) NOTES (PDP-11) On the PDP-11, longjmperror is called as _ljerr. This difference stems from the limited name size of the PDP-11 that requires all external names to be unique within the first seven characters. However, <setjmp.h> automatically translates longjmperror to ljerror and should be included before any definition longjmperror. The PDP-11 implementation also contains a subtle bug that occurs when a routine containing a setjmp has register variables. The bug some- times causes those variables to be given invalid values when a longjmp is made back to the routine. Register variables should therefore be avoided in routines containing setjmps. And finally, _longjmp may sometimes die fatally. Sorry. 4th Berkeley Distribution January 9, 1986 SETJMP(3)

Check Out this Related Man Page

SETJMP(3)						   BSD Library Functions Manual 						 SETJMP(3)

NAME
_longjmp, _setjmp, longjmp, longjmperror, setjmp, siglongjmp, sigsetjmp -- non-local jumps LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <setjmp.h> void _longjmp(jmp_buf env, int val); int _setjmp(jmp_buf env); void longjmp(jmp_buf env, int val); void longjmperror(void); int setjmp(jmp_buf env); void siglongjmp(sigjmp_buf env, int val); int sigsetjmp(sigjmp_buf env, int savemask); 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 most recent respective invocations of the 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() and 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 invo- cation duration that do not have the volatile type and have been changed between the setjmp() invocation and longjmp() call are indetermi- nate. The setjmp()/longjmp() pairs save and restore the signal mask while _setjmp()/_longjmp() 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 regis- ter 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(3)). 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
sigaction(2), sigaltstack(2), signal(3) STANDARDS
The setjmp() and longjmp() functions conform to ISO/IEC 9899:1990 (``ISO C90''). The sigsetjmp() and siglongjmp() functions conform to IEEE Std 1003.1-1988 (``POSIX.1''). BSD
June 4, 1993 BSD

Featured Tech Videos