This page needs to be proofread.
22. INTERRUPT HANDLERS
B.10
22. Interrupt handlers.
The following routines handle ctrl-brk and math exceptions. The routine ctrlbrk requires dos.h.
The routine signal requires signal. h.
⟨Include files 3⟩
#include <dos.h>
#include <signal.h>
23.
⟨Function declarations 23⟩
int control-break ( oid);
int matherr (struct exception *);
void div_0(void);
See also sections 33, 39, 43, 51, 54, 56, 59, 60, 61, and 65.
This code is used in section 2.
24. control-break handles interruptions due to the use striking CTRL-BRK during execution.
⟨Interrupt handlers 24⟩ int control-break (void) { int i, j, k ; printf("\n\n\tUSER CTRL-BRK!.\n\n); ⟨Print desired output 78⟩1 return 0; }
See also sections 25 and 26.
This code is used in section 2.
25. The routine matherr handles exceptions from the
math coprocessor.
⟨Interrupt handlers 24⟩ \
int matherr (struct exception *c)
{
printf/("\n\n");
printf("tmatherr: ");
switch (e-type) {
case DOMAIN: printf( "DOMAIN");
break;
case SING: printf( "SINGULARITY");
break;
case OVERFLOW: printf("0VERFL0W");
break;
case UNDERFLOW: printf("UNDERFLOW");
break;
case TLOSS: printf("TL0SS");
break;
default: printf("UNKN0WN ERR0R TYPE!");
break;
}
printf("\n");
printf("\n\n\t");
printf("function:\t%,s(%lf,%lf)\n", e-name e-arg1 e-arg2);
printf("\n");
exit(O);
}