- NetBSD Manual Pages
GETCONTEXT(2) NetBSD System Calls Manual GETCONTEXT(2)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
getcontext, setcontext -- get and set current user context
Standard C Library (libc, -lc)
setcontext(const ucontext_t *ucp);
The getcontext() function initializes the object pointed to by ucp to the
current user context of the calling thread. The user context defines a
thread's execution environment and includes the contents of its machine
registers, its signal mask, and its current execution stack.
The setcontext() function restores the user context defined in the object
pointed to by ucp as most recently initialized by a previous call to
either getcontext() or makecontext(3). If successful, execution of the
program resumes as defined in the ucp argument, and setcontext() will not
return. If ucp was initialized by the getcontext() function, program
execution continues as if the corresponding invocation of getcontext()
had just returned (successfully). If ucp was initialized by the
makecontext(3) function, program execution continues with the function
(and function arguments) passed to makecontext(3).
On successful completion, getcontext() returns 0 and setcontext() does
not return. Otherwise a value of -1 is returned and errno is set to
indicate the error.
The getcontext() and setcontext() functions will fail if:
[EFAULT] The ucp argument points to an invalid address.
The setcontext() function will fail if:
[EINVAL] The contents of the datum pointed to by ucp are
sigprocmask(2), longjmp(3), makecontext(3), setjmp(3), swapcontext(3)
The getcontext() and setcontext() functions conform to X/Open System
Interfaces and Headers Issue 5 (``XSH5''). The errno indications are an
extension to the standard.
The getcontext() and setcontext() functions first appeared in AT&T
System V.4 UNIX.
NetBSD 5.0.1 October 28, 1999 NetBSD 5.0.1