signal_handler.c, ft_sigintr(), exit after three SIGINT requests

This commit is contained in:
Francesco Lannutti 2015-07-05 13:08:59 +02:00 committed by rlar
parent 4778b48592
commit 0c5196e773
1 changed files with 9 additions and 0 deletions

View File

@ -73,6 +73,8 @@ ft_sigintr_cleanup(void)
RETSIGTYPE
ft_sigintr(void)
{
static int interrupt_counter = 0;
/* fprintf(cp_err, "Received interrupt. Handling it . . . . .\n"); */
/* Reinstall ft_signintr as the signal handler. */
@ -80,9 +82,16 @@ ft_sigintr(void)
if (ft_intrpt) { /* check to see if we're being interrupted repeatedly */
fprintf(cp_err, "\nInterrupted again (ouch)\n");
interrupt_counter++;
} else {
fprintf(cp_err, "\nInterrupted once . . .\n");
ft_intrpt = TRUE;
interrupt_counter = 1;
}
if (interrupt_counter >= 3) {
fprintf(cp_err, "\nKilling, since %d interrupts have been requested\n\n", interrupt_counter);
controlled_exit(1);
}
if (ft_setflag) {