Handling signals with POSIX(OFF) using signal() and raise()

The z/OS® XL C environment provides two functions that alter the signal handling capabilities available in the runtime environment: signal() and raise(). The signal() function registers a condition handler and the raise() function raises the condition.

In general, for C++ programs you are encouraged to use try, throw, and catch to perform exception handling. However, you can also use the z/OS XL C signal() and raise() functions.

You can use the signal() function to perform one of the following actions:
  • Ignore the condition. For example, use the SIG_IGN condition to specify signal(SIGFPE,SIG_IGN).
  • Reset the Global Error Table for default handling. For example, use the SIG_DFL condition to specify signal(SIGSEGV,SIG_DFL).
  • Register a function to handle the specific condition. For example, pass a pointer to a function for the specific condition with signal(SIGILL,cfunc1). The function registered for signal() must be declared with C linkage.