The IBM C and C++ Compilers library provides a default exception handling function, _Exception. This function is the C language exception handler. By default, _Exception is registered automatically for every process or thread launched by functions provided by IBM C and C++ Compilers. The default handler maps recognized OS/2 exceptions to C signals, which are then passed by the run-time library to the appropriate signal handlers.
Here is the prototype for _Exception:
#include <os2.h>
unsigned long _System _Exception(EXCEPTIONREPORTRECORD * report_rec,
EXCEPTIONREGISTRATIONRECORD * reg_rec,
CONTEXTRECORD * exc,
void * dummy);
The table below shows which types of OS/2 exceptions are recognized by _Exception, the names of the exceptions, and the C signals to which each exception type is mapped. These are the only OS/2 exceptions handled by _Exception. The table also shows whether the program can continue if the corresponding signal handler is SIG_IGN or if a user-defined signal handler returns. A No means that the program terminates unless the signal has a handler that calls longjmp to jump to transfer control.
If the signal handler value is set to SIG_DFL, the default action taken for each of these exceptions is to terminate the program with an exit code of 99.
| OS/2 Exception | C Signal | Continuable? |
|---|---|---|
Divide by
zero
|
SIGFPE | No |
NPX387 error
|
SIGFPE | No, except for XCPT_FLOAT_INEXACT_RESULT |
Overflow
occurred
|
SIGFPE | Yes, resets the overflow flag |
Bound opcode
failed
|
SIGFPE | No |
Opcode not
valid
|
SIGILL | No |
General
Protection fault
|
SIGSEGV | No |
Ctrl-Break
|
SIGBREAK | Yes |
Ctrl-C
|
SIGINT | Yes |
End process
|
SIGTERM | Yes |
![]()
Write or Register an Exception
Handler
Register an OS/2 Exception Handler
Using OS/2 APIs
![]()
Default Signal Handlers
Exception
Information Provided by OS/2
Prototype of an
OS/2 Exception Handler
How OS/2 Chains
Exception Handlers