Figure 1 contains a simple example of a C application in which y = a/b is a mathematical operation. signal (SIGFPE, c_handler) is a signal invocation that registers the routine c_handler() and gives it control if a floating-point divide exception occurs.
/*Module/File Name: EDCCSIG */
/**********************************************************************/
/* A routine with a C/370 condition handler registered. */
/**********************************************************************/
#include <stdio.h>
#include <signal.h>
#ifdef __cplusplus
extern "C" {
#endif
void c_handler(int);
#ifdef __cplusplus
}
#endif
int main(void) {
int a=8, b=0, y;
/* .
.
. */
signal (SIGFPE, c_handler);
/* .
.
. */
y = a/b;
/* .
. */
}
void c_handler(int i)
{
printf("handled SIGFPE\n");
/* .
. */
return;
}
The floating-point divide condition is enabled and enters the condition step of condition handling.