DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

sigsetjmp(S)


sigsetjmp -- a non-local goto with signal state

Synopsis

   #include <setjmp.h>
   

int sigsetjmp (sigjmp_buf env, int savemask);

void siglongjmp (sigjmp_buf env, int val);

Description

siglongjmp- a non-local goto with signal state

These functions are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program.

sigsetjmp saves the calling process's registers and stack environment [see sigaltstack(S)] in env (whose type, sigjmp_buf, is defined in the setjmp.h header file) for later use by siglongjmp. If savemask is non-zero, the calling process's signal mask [see sigprocmask(S)] and scheduling parameters [see priocntl(S)] are also saved. sigsetjmp returns the value 0.

siglongjmp restores the environment saved by the last call of sigsetjmp with the corresponding env argument. After siglongjmp is completed, program execution continues as if the corresponding call of sigsetjmp had just returned the value val. siglongjmp cannot cause sigsetjmp to return the value zero. If siglongjmp is invoked with a second argument of zero, sigsetjmp will return 1. At the time of the second return from sigsetjmp, all external and static variables have values as of the time siglongjmp is called. The values of register and automatic variables are undefined. Register or automatic variables whose value must be relied upon must be declared as volatile.

If a signal-catching function interrupts sleep and calls siglongjmp to restore an environment saved prior to the sleep call, the action associated with SIGALRM and time it is scheduled to be generated are unspecified. It is also unspecified whether the SIGALRM signal is blocked, unless the process's signal mask is restored as part of the environment.

The function siglongjmp restores the saved signal mask if and only if the env argument was initialized by a call to the sigsetjmp function with a non-zero savemask argument.

References

getcontext(S), priocntl(S), setjmp(S), sigaction(S), sigaltstack(S), sigprocmask(S)

Notices

If siglongjmp is called even though env was never primed by a call to sigsetjmp, or when the last such call was in a function that has since returned, the behavior is undefined.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005