1GETCONTEXT(2)              Linux Programmer's Manual             GETCONTEXT(2)
2
3
4

NAME

6       getcontext, setcontext - get or set the user context
7

SYNOPSIS

9       #include <ucontext.h>
10
11       int getcontext(ucontext_t *ucp);
12       int setcontext(const ucontext_t *ucp);
13
14       where:
15
16       ucp    points  to  a  structure  defined in <ucontext.h> containing the
17              signal mask, execution stack, and machine registers.
18

DESCRIPTION

20       getcontext(2) gets the current context of the calling process,  storing
21       it in the ucontext struct pointed to by ucp.
22
23       setcontext(2)  sets  the  context  of  the calling process to the state
24       stored in the ucontext struct pointed to by ucp. The struct must either
25       have  been  created  by  getcontext(2) or have been passed as the third
26       parameter of the sigaction(2) signal handler.
27
28       The ucontext struct created by getcontext(2) is defined in <ucontext.h>
29       as follows:
30
31              typedef struct ucontext
32                {
33                    unsigned long int uc_flags;
34                    struct ucontext *uc_link;
35                    stack_t uc_stack;
36                    mcontext_t uc_mcontext;
37                    __sigset_t uc_sigmask;
38                    struct _fpstate __fpregs_mem;
39                  } ucontext_t;
40

RETURN VALUES

42       getcontext(2)  returns  0  on success and -1 on failure.  setcontext(2)
43       does not return a value on success and returns -1 on failure.
44

STANDARDS

46       These functions comform to: XPG4-UNIX.
47

NOTES

49       When a signal handler executes, the current user context is saved and a
50       new  context  is  created by the kernel.  If the calling process leaves
51       the signal handler using longjmp(2), the  original  context  cannot  be
52       restored,  and  the  result of future calls to getcontext(2) are unpre‐
53       dictable. To avoid this problem, use siglongjmp(2) or setcontext(2)  in
54       signal handlers instead of longjmp(2).
55

SEE ALSO

57       sigaction(2), sigaltstack(2), sigprocmask(2), sigsetjmp(3), setjmp(3).
58
59
60
61Red Hat Linux 6.1              20 September 1999                 GETCONTEXT(2)
Impressum