Previous Topic Next topic Print topic


Signal Handling Overview

The run-time system sets up default signal handlers for all signals whose operating system default action is to cause termination. These default handlers make sure that the COBOL system is properly cleaned up before terminating. Hence, any open files are closed (to prevent file corruption), the PC is reset to a sane state, user posted exit and error procedures are executed, and so on.

You can complement or override the signal handling used by the run-time system by using the following routines:

These routines allow multiple handlers for each signal and enable you to prioritize use of these handlers. You can use them from inside a C program only, not least because you need the C library include file <signal.h> for the signal values, which vary between platforms.

Use these routines instead of the operating system signal calls, (signal() and so on) which provide only the ability to post a single signal handler for each call and so often prevent multiple applications being able to work together reliably.

For example, if you use one of the C library signal calls to post a signal handler before invoking a COBOL program, your signal handler might be overridden. Whereas, if you use one of the C library signal calls after invoking a COBOL program, the default run-time system handler, additional COBOL functionality and user-posted signal handlers are all overridden, causing unexpected results.

Previous Topic Next topic Print topic