ILE C/C++ Programmer's Guide

Example of Using a Direct Monitor Handler and Signal Handler Together

The following example shows you how to use the #pragma exception_handler directive and the signal() function together. This example also shows how an exception is handled using SIGIO. An end-of-file message is mapped to SIGIO. The default for SIGIO is SIG_IGN. It also shows that when both a HLL-specific handler and direct monitor handler are defined, the direct monitor handler is called first.

This example uses the source shown in Figure 171.

  1. To create the program T1520ICA, enter:

    CRTBNDC PGM(MYLIB/T1520ICA) SRCFILE(QCPPLE/QACSRC)
  2. To run the program T1520ICA, enter:

    CALL PGM(MYLIB/T1520ICA)

    The first screen of output is shown below:

    +--------------------------------------------------------------------------------+
    |  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 direct monitor handler                                                     |
    |  Exception message ID is CPF5001                                               |
    |  The second read finishes                                                      |
    |  The third read starts                                                         |
    |  Read record 1                                                                 |
    +--------------------------------------------------------------------------------+

    The second screen of output follows:

    +--------------------------------------------------------------------------------+
    |  Read record 2                                                                 |
    |  Read record 3                                                                 |
    |  Read record 4                                                                 |
    |  Read record 5                                                                 |
    |  In direct monitor handler                                                     |
    |  Exception message ID is CPF5001                                               |
    |  In signal handler                                                             |
    |  Exception message ID is CPF5001                                               |
    |  The third read finishes                                                       |
    |  The fourth read starts                                                        |
    |  Read record 1                                                                 |
    |  Read record 2                                                                 |
    |  Read record 3                                                                 |
    |  Read record 4                                                                 |
    |  Read record 5                                                                 |
    |  In signal handler                                                             |
    |  Exception message ID is CPF5001                                               |
    |  The fourth 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                               |
    +--------------------------------------------------------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents ]