sigsetjmp

Is a macro that saves the calling environment and signal mask for subsequent use by the siglongjmp function.

Library:LibC
Classification:ANSI
Service:General C Services

Syntax

  #include <setjmp.h> 
   
  int sigsetjmp (
     sigjmp_buf   env,
     int          savemask ); 
  

Parameters

env

(IN) Specifies the buffer in which to save the environment.

savemask

(IN) Specifies wether the signal mask is saved. If non-zero, the signal mask is saved.

Return Values

This macro returns a value of 0 when it is initially called. The return value is nonzero if the return is the result of a call to the siglongjmp function. An if statement is often used to handle these two returns. When the return value is 0, the initial call to sigsetjmp has been made; when the return value is nonzero, a return from a siglongjmp has just occurred.

Remarks

In some cases, error handling can be implemented by using sigsetjmp to record the point to which a return occurs following an error. When an error is detected in a called function, that function uses siglongjmp to jump back to the recorded position. The original function which called sigsetjmp must still be active (it cannot have returned to the function which called it).

Special care must be exercised to ensure that any side effects that have occurred (such as allocated memory and opened files) are satisfactorily handled.

See Also

siglongjmp