1.TH SETJMP 3 scc\-VERSION2.SH NAME3setjmp - save and restore the calling environment for non-local jumps4.SH SYNOPSIS5#include <setjmp.h>67.nf8int setjmp(jmp_buf env)9void longjmp(jmp_buf env, int val)10.fi11.SH DESCRIPTION12The13.BR setjmp ()14function saves the current execution environment into15.IR env ,16which may later be passed to17.BR longjmp ()18to transfer control back to the point of the19.B setjmp20call.2122The23.BR longjmp ()24function restores the execution environment previously captured by25.B setjmp26in the same program invocation, using the matching27.I env28buffer.2930Calling31.BR longjmp ()32is only valid if the corresponding33.B setjmp34was made in the same program invocation,35the function that called36.B setjmp37has not yet returned,38and execution has not left the scope of any variably modified type39that was in scope at the time of the40.B setjmp41call.42Violating these conditions produces undefined behavior.43.SH RETURN VALUE44When called directly,45.B setjmp46returns zero.47When control is transferred via48.BR longjmp ,49.B setjmp50returns a non-zero value.5152After53.B longjmp54is called, execution resumes as though55.B setjmp56had just returned57.IR val .58If59.I val60is zero,61.B setjmp62returns 1 instead.63.SH STANDARDS64.nf65ISO/IEC 9899:1999 Section 7.13.1.1 Paragraph 1,2,366ISO/IEC 9899:1999 Section 7.13.2.1 Paragraph 1,2,3,467.fi68.SH SEE ALSO69.BR setjmp.h (3)