The following example shows how to set up a signal handler. The example illustrates that when there is no signal handler set up the default action for SIGIO is SIG_IGN. The exception is ignored. When a signal handler is set up for SIGIO, the signal handler is called.
Figure 182 shows the source code.
CRTBNDC PGM(MYLIB/T1520SIG) SRCFILE(QCPPLE/QACSRC)
The output appears in a series of screens:
CALL PGM(MYLIB/T1520SIG)
+--------------------------------------------------------------------------------+ | The first read starts | | Read record 1 | | Read record 2 | | Read record 3 | | Read record 4 | | Read record 5 | +--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+ | The first read finishes | | The second read starts | | Read record 1 | | Read record 2 | | Read record 3 | | Read record 4 | | Read record 5 | | In SIGIO handler | | Exception message ID is CPF5001 | | Signal raised is 9 | | The second read finishes | | The third read starts | | Read record 1 | | Read record 2 | | Read record 3 | | Read record 4 | | Read record 5 | | In SIGALL handler | | Exception message ID is CPF5001 | | Signal raised is 9 | | The third read finishes | | Press ENTER to end terminal session. | | ===> | | F3=Exit F4=End of File F6=Print F9=Retrieve F17=Top | | F18=Bottom F19=Left F20=Right F21=User Window | +--------------------------------------------------------------------------------+
Figure 182. T1520SIG -- ILE C Source that Sets Up Signal Handlers
|
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.