In
31-bit mode, you can set up user signal handlers with the
z/OS® Language Environment® condition
handling services. Some of the
z/OS Language
Environment callable services available for
condition handling are:
- CEEHDLR
- Register a user-written condition handler.
- CEEHDLU
- Remove a registered user-written condition handler.
- CEESGL
- Raise z/OS Language
Environment condition.
In addition, with
z/OS Language
Environment, when an exception occurs after an
interlanguage call, the exception may be handled where it occurs,
or percolated to its caller (written in any
z/OS Language
Environment-conforming language),
or promoted. For more information on how to handle exceptions under
the
z/OS Language
Environment condition handling model, refer to
z/OS Language Environment Programming Guide.
Specific considerations for C and under : - The TRAP runtime option (equivalent to the former C/370™ runtime
options SPIE and STAE) determines how the z/OS Language
Environment condition manager
is to act upon error conditions and program interrupts. If the TRAP(OFF) runtime
option is in effect, conditions detected by the operating system,
often due to machine interrupts, will not be handled by the z/OS Language
Environment environment
and thus cannot be handled by a z/OS XL C/C++ program.
Note: TRAP(OFF) only
blocks the handling of hardware (program checks) and operating system
(abend) conditions. It does not block software conditions such those
that are associated with a raise or CEESGL (31-bit mode).
Any conditions that are blocked because of TRAP(OFF) are
not presented to any handlers (whether registered by a signal or by CEEHDLR).
In particular, even for TRAP(OFF), conditions that are
initiated by a signal or by CEESGL (31-bit mode) are presented
to handlers registered by either signal() or CEEHDLR.
The use of the TRAP(OFF) option is not recommended;
refer to z/OS Language Environment Programming Reference for more information.
- You can use the ERRCOUNT runtime option to specify
how many errors are to be tolerated during the execution of your program
before an abend occurs. The counter is incremented by one for every severity 2,
3, or 4 condition that occurs. Both hardware-generated and software-generated
signals increment the counter.
If your C++ program uses try, throw,
and catch, it is recommended that you specify either ERRCOUNT(0) (31-bit mode),
which allows an unlimited number of errors, or ERRCOUNT(n) (31-bit mode),
where n is a fairly high number. This is because z/OS XL C++ generates
a severity 3 condition for each thrown object. In addition, each catch clause
has the potential to rethrow an object or to throw a new object.
In a large C++ program, many conditions can be generated as a result
of objects being thrown, and thus the ERRCOUNT can be exceeded
if the value used for it is too low. The default used for ERRCOUNT is
usually a low number.
Note: The
z/OS XL C/C++ registered condition handlers (those registered
by
signal() and
raise()), are activated after the
z/OS Language
Environment registered
condition handlers for the current stack frame are activated. This
means that if there are condition handlers for both
z/OS XL C/C++ and
z/OS Language
Environment,
the
z/OS Language
Environment handlers are activated first.
Combining C++ condition
handling (using try, throw, and catch),
with z/OS Language
Environment condition handling may result in undefined behavior.