1. Home
  2. Computing & Technology
  3. Linux
Linux / Unix Command: getcontext
Command Library

NAME

getcontext, setcontext - get or set the user context  

SYNOPSIS

#include <ucontext.h>

int getcontext(ucontext_t *ucp);
int setcontext(const ucontext_t *ucp);

where:

ucp
points to a structure defined in <ucontext.h> containing the signal mask, execution stack, and machine registers.
 

DESCRIPTION

getcontext(2) gets the current context of the calling process, storing it in the ucontext struct pointed to by ucp.

setcontext(2) sets the context of the calling process to the state stored in the ucontext struct pointed to by ucp. The struct must either have been created by getcontext(2) or have been passed as the third parameter of the sigaction(2) signal handler.

The ucontext struct created by getcontext(2) is defined in <ucontext.h> as follows:

typedef struct ucontext
  {
      unsigned long int uc_flags;
      struct ucontext *uc_link;
      stack_t uc_stack;
      mcontext_t uc_mcontext;
      __sigset_t uc_sigmask;
      struct _fpstate __fpregs_mem;
    } ucontext_t;
 

RETURN VALUES

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

STANDARDS

These functions comform to: XPG4-UNIX.  

SEE ALSO

sigaction(2), sigaltstack(2), sigprocmask(2), sigsetjmp(3), setjmp(3).


Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux/Unix Command Library

>> Shell Command Library

Explore Linux

More from About.com

  1. Home
  2. Computing & Technology
  3. Linux

©2008 About.com, a part of The New York Times Company.

All rights reserved.