Home Man
Today's Posts

Linux & Unix Commands - Search Man Pages

NetBSD 6.1.5 - man page for setjmp (netbsd section 3)

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

     sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp, longjmperror -- non-local jumps

     Standard C Library (libc, -lc)

     #include <setjmp.h>

     sigsetjmp(sigjmp_buf env, int savemask);

     siglongjmp(sigjmp_buf env, int val);

     setjmp(jmp_buf env);

     longjmp(jmp_buf env, int val);

     _setjmp(jmp_buf env);

     _longjmp(jmp_buf env, int val);


     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 invo-
     cation of the respective setjmp() function.  They then return so that program execution con-
     tinues 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() rou-
     tines 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 indetermi-

     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.

     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().

     sigaction(2), sigaltstack(2), sigprocmask(2), pthread_sigmask(3), signal(3)

     The setjmp() and longjmp() functions conform to ANSI X3.159-1989 (``ANSI C89'').  The
     sigsetjmp() and siglongjmp() functions conform to ISO/IEC 9945-1:1990 (``POSIX.1'').

     Historically, on AT&T System V UNIX, the setjmp()/longjmp() functions have been equivalent
     to the BSD _setjmp()/_longjmp() functions and do not restore the signal mask.  Because of
     this discrepancy, the sigsetjmp()/siglongjmp() interfaces should be used if portability is

     Use of longjmp() or siglongjmp() from inside a signal handler is not as easy as it might
     seem.  Generally speaking, all possible code paths between the setjmp() and longjmp() must
     be signal race safe.  Furthermore, the code paths must not do resource management (such as
     open(2) or close(2)) without blocking the signal in question, or resources might be misman-
     aged.  Obviously this makes longjmp() much less useful than previously thought.

BSD					   June 1, 2008 				      BSD

All times are GMT -4. The time now is 11:04 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password