The following three figures illustrate how a condition such as a divide-by-zero is handled in a C routine in Language Environment if you do not use any Language Environment callable services, or don't have any user-written condition handlers registered.
There is no user-written condition handler or signal handler registered for C370C or any of the other C routines, so the condition is percolated through all of the stack frames on the stack. At this point, C default actions take place of percolating the condition to Language Environment. Language Environment takes its default action for an unhandled severity 3 condition and terminates the application. A message, trace, Language Environment dump, or a user address space dump could be generated depending on the setting of TERMTHDACT (see z/OS Language Environment Programming Reference).
Figure 1 is a C main routine that calls C370B, a subroutine that passes data to another subroutine, C370C.
/*Module/File Name: EDCMLTA */
/*******************************************************************/
/* Demonstrate a failing C/370 program */
/* with multiple active routines */
/* on the stack. The call sequence is as follows: */
/* C370A ---> C370B ---> C370C (which does a divide-by-zero) */
/*******************************************************************/
#include <stdio.h>
int y = 0;
void C370B(void);
int main(void) {
printf("In Program C370A\n");
C370B();
}
Figure 2 is a C subroutine that calls C370C, and passes data to it.
/*Module/File Name: EDCMLTB */
/**********************************************************************/
/* This routine is called to pass data forward to C370C. */
/* C370C will then cause a zero divide. */
/**********************************************************************/
#include <stdio.h>
extern int y;
void C370C(int);
void C370B(void) {
int x;
printf("In Program C370B\n");
x = y;
C370C(x);
}
Figure 3 generates a divide-by-zero. The divide-by-zero condition is percolated back to C370B, to C370A, and to Language Environment default behavior.
/*Module/File Name: EDCMLTC */
/**********************************************************************/
/* This routine is called by C370B to generate a zero divide. */
/**********************************************************************/
#include <stdio.h>
void C370C(int y) {
printf("In Program C370C\n");
y = 1/y;
}