Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
setjmp(3C)							    setjmp(3C)

NAME
       setjmp(), longjmp(), sigsetjmp(), siglongjmp() -	non-local goto

SYNOPSIS
DESCRIPTION
       and  are	useful for dealing with	errors and interrupts encountered in a
       low-level subroutine of a program.  They	exist in three variant	forms:
       and  and	and Unless indicated otherwise,	references to and apply	to all
       three versions.

	      saves its	stack environment in
				env (whose type,  is  defined  in  the	header
				file) for later	use by It returns the value

	      restores the environment saved by	the last call of
				with the corresponding env argument.  After is
				completed, program execution continues	as  if
				the  corresponding call	of (which must not it-
				self have returned in the  interim)  had  just
				returned  the  value val.  cannot cause	to re-
				turn the value If is invoked with a second ar-
				gument	of  returns All	accessible data	values
				are valid as of	the time is called.

       Upon the	return from a call caused by a the values of any non-static or
       non-volatile  local  variables  belonging to the	routine	from which was
       called are undefined.  Code which depends on such values	is not guaran-
       teed to be portable.

   Variant Forms
       The  following  functions behave	the same as and	except in the handling
       of the process' signal mask (see	sigaction(2) and sigvector(2)).	  This
       distinction is only significant for programs which use and/or

	      These always save	and restore the	signal mask.

	      These never manipulate the signal	mask.

	      Saves the	signal mask of the calling thread if and only if
				savemask is non-zero.

	      Restores the signal mask if and only if it is saved by

   Programming Considerations
       If a is executed	and the	environment in which the is executed no	longer
       exists, errors can occur.  The conditions under which  the  environment
       of the no longer	exists include exiting the procedure that contains the
       call, and exiting an inner block	with  temporary	 storage  (such	 as  a
       block with declarations in C or a statement in Pascal).	This condition
       might not be detectable,	in which case the occurs and, if the  environ-
       ment  no	longer exists, the contents of the temporary storage of	an in-
       ner block are unpredictable.  This condition  might  also  cause	 unex-
       pected  process	termination.  If the procedure has been	exited the re-
       sults are unpredictable.

       Passing a pointer to a buffer not created by passing  a	pointer	 to  a
       buffer  not created by either or	passing	a pointer to a buffer not cre-
       ated by or passing any of these three functions a buffer	that has  been
       modified	 by  the  user,	 can  cause all	the problems listed above, and
       more.

       Some implementations of Pascal  support	a  ``try/recover''  mechanism,
       which  also creates stack marker	information.  If a operation occurs in
       a scope which is	nested inside a	try/recover, and the corresponding  is
       not  inside the scope of	the try/recover, the recover block will	not be
       executed	and the	currently active recover block will become the one en-
       closing the if one exists.

WARNINGS
       A  call to to leave the guaranteed stack	space reserved by might	remove
       the guarantee that the ordinary execution of the	program	will  not  ex-
       tend  into  the	guaranteed  space.  It might also cause	the program to
       forever lose its	ability	to automatically increase the stack size,  and
       the program might then be limited to the	guaranteed space.

       The result of using within an expression	can be unpredictable.

       If  is called even though env was never primed by a call	to or when the
       last such call was in a function	that has since returned,  total	 chaos
       is guaranteed.

       The  effect  of	a call to where	the initialization of the argument was
       not performed in	the calling thread is undefined.  The effect of	a call
       to  where  the  initialization of the argument was not performed	in the
       calling thread is undefined.

       The contents of the buffer are architecture and compilation environment
       specific.   Thus,  objects  built using these functions may not be sup-
       ported across architectures.

AUTHOR
       was developed by	AT&T and HP.

SEE ALSO
       sigaction(2), sigblock(2),  signal(5),  sigprocmask(2),	sigsetmask(2),
       sigspace(2), sigsuspend(2), sigvector(2), thread_safety(5).

STANDARDS CONFORMANCE
								    setjmp(3C)

NAME | SYNOPSIS | DESCRIPTION | WARNINGS | AUTHOR | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=setjmp&sektion=3c&manpath=HP-UX+11.22>

home | help