Handling error conditions, exceptions, and signals
This topic discusses how to handle error conditions, exceptions, and signals with z/OS® XL C/C++. It describes how to establish, enable and raise a signal, and provides a list of signals supported by z/OS XL C/C++.
- POSIX or ANSI signals (SIGABND, SIGFPE, SIGILL, SIGSEGV)
- User condition handlers registered using CEEHDLR interface or the USRHDLR runtime option.
In 31-bit applications, z/OS Language Environment® uses
a stack-based model to handle error conditions. This environment establishes
a last-in, first-out (LIFO) queue of 0
or more user
condition handlers for each stack frame. The z/OS Language
Environment condition
handler calls the user condition handler at each stack frame to handle
error conditions when they are detected. For more information about
the callable services in z/OS Language
Environment, refer
to Handling signals using Language Environment callable services.
- POSIX or ANSI signals (SIGABND, SIGFPE, SIGILL, SIGSEGV)
- Exception handlers registered using the __set_exception_handler() C runtime library function. See AMODE 64 exception handlers for more information.
The C error handling approach using signals is supported in a z/OS XL C/C++ program, but there are some restrictions (refer to Handling C software exceptions under C++). See Signal handlers for more information.
TRAP(ON)
runtime option. To turn off C++ exception
handling, use the compiler option NOEXH
. For more information on this compiler
option, see z/OS XL C/C++ User's Guide. This topic also describes some aspects of C++
object-oriented exception handling. The object-oriented approach uses the try
,
throw
, and catch
mechanism. Refer to z/OS XL C/C++ Language Reference for a complete description.
Some library functions (abort()
, atexit()
,
exit()
, setjmp()
and longjmp()
) are affected by
C++ exception handling; refer to z/OS XL C/C++ Runtime Library Reference for more information.