.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "LONGJMP" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" longjmp 
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
longjmp \- non-local goto
.SH SYNOPSIS
.LP
\fB#include <setjmp.h>
.br
.sp
void longjmp(jmp_buf\fP \fIenv\fP\fB, int\fP \fIval\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
The \fIlongjmp\fP() function shall restore the environment saved by
the most recent invocation of \fIsetjmp\fP() in the same thread, with
the corresponding \fBjmp_buf\fP argument. If there is no
such invocation, or if the function containing the invocation of \fIsetjmp\fP()
has
terminated execution in the interim, or if the invocation of \fIsetjmp\fP()
was within the
scope of an identifier with variably modified type and execution has
left that scope in the interim, the behavior is undefined.
\ It is unspecified whether \fIlongjmp\fP() restores the signal mask,
leaves the signal mask unchanged, or restores it to its
value at the time \fIsetjmp\fP() was called. 
.LP
All accessible objects have values, and all other components of the
abstract machine have state (for example, floating-point
status flags and open files), as of the time \fIlongjmp\fP() was called,
except that the values of objects of automatic storage
duration are unspecified if they meet all the following conditions:
.IP " *" 3
They are local to the function containing the corresponding \fIsetjmp\fP()
invocation.
.LP
.IP " *" 3
They do not have volatile-qualified type.
.LP
.IP " *" 3
They are changed between the \fIsetjmp\fP() invocation and \fIlongjmp\fP()
call.
.LP
.LP
As
it bypasses the usual function call and return mechanisms, \fIlongjmp\fP()
shall execute correctly in contexts of interrupts,
signals, and any of their associated functions. However, if \fIlongjmp\fP()
is invoked from a nested signal handler (that is, from
a function invoked as a result of a signal raised during the handling
of another signal), the behavior is undefined.
.LP
The effect of a call to \fIlongjmp\fP() where initialization of the
\fBjmp_buf\fP structure was not performed in the calling
thread is undefined. 
.SH RETURN VALUE
.LP
After \fIlongjmp\fP() is completed, program execution continues as
if the corresponding invocation of \fIsetjmp\fP() had just returned
the value specified by \fIval\fP. The \fIlongjmp\fP() function
shall not cause \fIsetjmp\fP() to return 0; if \fIval\fP is 0, \fIsetjmp\fP()
shall return 1.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
Applications whose behavior depends on the value of the signal mask
should not use \fIlongjmp\fP() and \fIsetjmp\fP(), since their effect
on the signal mask is unspecified, but should instead use the \fIsiglongjmp\fP()
and \fIsigsetjmp\fP()
functions (which can save and restore the signal mask under application
control).
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIsetjmp\fP(), \fIsigaction\fP(), \fIsiglongjmp\fP(), \fIsigsetjmp\fP(),
the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<setjmp.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
