Language Environment and POSIX signal handling interactions

If you want to run an application that uses POSIX signal handling functions under z/OS UNIX, you need to know how Language Environment condition handling might affect your application. For a detailed discussion of POSIX signal handling functions, see z/OS XL C/C++ Programming Guide. For details about the Language Environment condition handling model, see Introduction to Language Environment condition handling.

In Language Environment, POSIX signals are distinguished as follows:
Synchronous Signal Handling
If a signal is delivered to the thread that caused the signal to be sent (the incurring thread), and the signal is not blocked, Language Environment’s synchronous signal handling semantics apply and you can use Language Environment condition services to handle the condition as described in Synchronous POSIX signal and Language Environment condition handling interactions. Like asynchronous signals, synchronous POSIX signals do not increment the ERRCOUNT error count.
Asynchronous Signal Handling
Asynchronous signals include the following:
  • Signals generated because of a kill(), raise(), pthread_kill(), killpg() or sigqueue() (on MVS™) in a multithread environment that are delivered to a thread that did not cause the signal to be sent.
  • Signals generated because of a kill(), killpg() or sigqueue() (on MVS) from a different POSIX process.
  • All signals that were blocked when first sent, and later unblocked.
  • Signals generated by an external interrupt not caused by any specific thread. For example, signals can be generated in response to a command typed in at the terminal.
  • SIGCHLD, which is sent to a parent process when one of its child processes terminates.
  • Signals, such as SIGALRM, generated by the kernel.

Asynchronous signals are handled according to the semantics defined by POSIX. Language Environment condition handling semantics do not apply; for example, the ERRCOUNT runtime option does not increment its error count when an asynchronous signal is sent.

POSIX signal handling can take effect even if no C routine is present on the stack. For example, a COBOL program calls C routine C1. C1 registers a POSIX signal catcher, then C1 returns control to the COBOL program. The registered POSIX signal handler would still be present to handle a POSIX signal even though the stack no longer contains a C stack frame.