内容简介
#include <ucontext.h> int getcontext(ucontext_t *ucp)%uA0 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. |
描述
getcontext(2) gets the current context of the calling process, storing it in the ucontext struct pointed to by%uA0ucp.setcontext(2) sets the context of the calling process to the state stored in the ucontext struct pointed to by%uA0ucp. The struct must either have been created by%uA0getcontext(2) or have been passed as the third parameter of the%uA0sigaction(2) signal handler.
The ucontext struct created by%uA0getcontext(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.%uA0setcontext(2) does not return a value on success and returns -1 on failure.STANDARDS
These functions comform to: XPG4-UNIX.注意
When a signal handler executes, the current user context is saved and a new context is created by the kernel. If the calling process leaves the signal handler using%uA0longjmp(2), the original context cannot be restored, and the result of future calls to%uA0getcontext(2) are unpredictable. To avoid this problem, use%uA0siglongjmp(2) or%uA0setcontext(2) in signal handlers instead of%uA0longjmp(2).另请参阅
-
sigaltstack(2),%uA0sigprocmask(2),%uA0sigsetjmp(3),%uA0setjmp(3).%uA0