GETCONTEXT(3) Library Functions Manual GETCONTEXT(3)

getcontext setcontextget and set current user context

#include <ucontext.h>

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

The getcontext() function initialises the structure pointed to by ucp to the current user context of the calling thread. The ucontext_t type that ucp points to defines the user context and includes the contents of the calling thread's machine registers, the signal mask, and the current execution stack.

On successful completion, setcontext(3) does not return and getcontext() returns 0. Otherwise, a value of -1 is returned.

No errors are defined.

None.

When a signal handler is executed, the current user context is saved and a new context is created. If the thread leaves the signal handler via longjmp(3) , then it is unspecified whether the context at the time of the corresponding setjmp(3) call is restored and thus whether future calls to getcontext() will provide an accurate representation of the current context, since the context restored by longjmp(3) does not necessarily contain all the information that setcontext(3) requires. Signal handlers should use siglongjmp(3) or setcontext(3) instead.

Portable applications should not modify or access the member of ucontext_t. A portable application cannot assume that context includes any process-wide static data, possibly including . Users manipulating contexts should take care to handle these explicitly when required.

Use of contexts to create alternate stacks is not defined by this specification.

None.

bsd_signal(3) , makecontext(3) , setjmp(3) , sigaction(3) , sigaltstack(3) , sigprocmask(3) , sigsetjmp(3) , <ucontext.h> .

February 1997 posix.fail