1SETJMP(3)                      Library functions                     SETJMP(3)
2
3
4

NAME

6       setjmp, sigsetjmp - save stack context for non-local goto
7

SYNOPSIS

9       #include <setjmp.h>
10
11       int setjmp(jmp_buf env);
12       int sigsetjmp(sigjmp_buf env, int savesigs);
13

DESCRIPTION

15       setjmp()  and  longjmp()  are useful for dealing with errors and inter‐
16       rupts encountered in a low-level subroutine  of  a  program.   setjmp()
17       saves  the stack context/environment in env for later use by longjmp().
18       The stack context will be invalidated  if  the  function  which  called
19       setjmp() returns.
20
21       sigsetjmp()  is  similar to setjmp().  If savesigs is non-zero, the set
22       of blocked signals is saved in env and  will  be  restored  if  a  sig‐
23       longjmp() is later performed with this env.
24

RETURN VALUE

26       setjmp()  and  sigsetjmp() return 0 if returning directly, and non-zero
27       when returning from longjmp() using the saved context.
28

CONFORMING TO

30       C89, C99, and POSIX.1-2001 specify  setjmp().   POSIX.1-2001  specifies
31       sigsetjmp().
32

NOTES

34       POSIX  does  not specify whether setjmp() will save the signal context.
35       (In System V it will not. In 4.3BSD it will, and there  is  a  function
36       _setjmp  that  will  not.)   If  you  want  to  save  signal masks, use
37       sigsetjmp().
38
39       setjmp() and sigsetjmp() make programs hard to understand and maintain.
40       If possible an alternative should be used.
41

SEE ALSO

43       longjmp(3), siglongjmp(3)
44
45
46
47                                  1997-03-02                         SETJMP(3)
Impressum