Restriction: The following applies to native COBOL only.
If you have any signal handlers that are posted using a C library signal call, such as signal(), change them to use the cobpostsighandler()
routine. This is so that your handler and any default run-time system handler, additional COBOL functionality and user-posted
signal handlers can all co-exist without one overriding the other, causing unexpected results.
The cobpostsighandler() routine interface is very similar to the signal() interface. The two parameters you pass to signal()
are also passed to the cobpostsighandler() routine, plus a priority.
The differences between signal() and the cobpostsighandler() routine are:
- The return value from signal() is the previous signal handler that was posted for the signal. This is returned because signal()
allows only one handler per signal. The cobpostsighandler() routine allows multiple handlers per signal.
The return value from cobpostsighandler() is either a pointer or NULL. You use this pointer to remove your handler later using
cobremovesighandler(). If the return value is NULL, the handler was not posted for the signal.
- A signal handler function that you post using cobpostsighandler() needs to return an integer value, whereas a signal handler
function that you install using signal() needs to return no value.
- A signal handler posted using C library signal calls can be terminated by functions such as longjmp() and siglongjmp(), but
a signal handler posted using the cobpostsighandler() routine cannot be terminated by these routines. If you try to do this,
the signal is blocked, and further signals cannot be processed.
- A signal handler function posted using signal() needs to repost itself, using another signal() call, if it wants to catch
subsequent signals. This is because the operating system resets the signal to the operating system default handler before
the signal handler function is called.
By contrast, you do not need to repost a handler that you posted using cobpostsighandler() routine; it stays posted. If you
want your handler to be executed only once, remove it using the cobremovesighandler() routine.