Scenario 2: User-written condition handler present for T_I_U

Scenario 2 is much the same as Scenario 1, except that routine A does have a user-written condition handler established. Refer to Figure 1 throughout the following scenario.

Figure 1. Scenario 2: Division by zero with a user-written condition handler present in routine A
With a condition handler in routine A, a divide-by-zero condition occurs in routine B.

In this scenario, routine A is a routine that invokes other prewritten applications. If any of the components of the prewritten application fail, routine A must remain up and take alternate action. Therefore, routine A has a user-written condition handler registered. The handler is designed to handle the T_I_U condition by issuing a nonlocal jump to a location within routine A. The handler percolates all conditions other than T_I_U.

  1. A divide-by-zero exception occurs in routine B.
  2. The divide-by-zero exception is enabled by the language of the stack frame in which it occurred because it is a problem that, if it remains unhandled, causes termination.
  3. The following occurs in the condition step:
    • If a user-written condition handler has been registered for the divide-by-zero condition on routine B's stack frame, it is given control. One has not been registered, so the condition is percolated.
    • If a C/C++ signal handler has been registered or a PL/I ON-unit has been established for the divide-by-zero condition, it is given control. No C/C++ signal handler or ON-unit is present, so the condition is percolated to Language Environment.
    • If a user-written condition handler has been registered on routine A's stack frame, it is given control. However, because the divide-by-zero condition is not the one the handler is looking for, the condition is percolated.
    • If a C/C++ signal handler is registered or a PL/I ON-unit is established for the condition on routine A's stack frame, it is given control. Neither one is present, so the condition is percolated.
    • After the earliest stack frame (in this case, that for routine A) has been checked, HLL and Language Environment default actions occur. In this case, assume that the HLL percolates the condition to Language Environment.

      Language Environment examines the severity of the unhandled divide-by-zero condition (severity 3), promotes the condition to T_I_U, and requests that the stack be redriven. This is the end of the condition step and the beginning of the termination imminent step.

  4. The following occurs during the termination imminent step:
    • Language Environment revisits the stack frame for routine B, checking for user-written condition handlers registered for the T_I_U condition. No handlers are registered, so T_I_U is percolated.
    • If a PL/I FINISH ON-unit is present, it is given control. In this example, there isn't one, so the condition is percolated.
    • Language Environment revisits the stack frames for routine A, checking for user-written condition handlers registered for the T_I_U condition. There is one, it is given control. The user code in the handler, using either HLL or Language Environment facilities, causes control to pass to a location within routine A.
  5. Control resumes with routine A at the location specified. The condition is now handled.