Files
Le-Compte-est-Bon/signal.c

34 lines
641 B
C

#include <stdio.h>
#include <signal.h>
int sigint_received=0;
static void stopall()
{
printf("SIGINT RECEIVED: aborting eval\n");
sigint_received=1;
}
int stopped()
{
return sigint_received;
}
void set_intr()
{
struct sigaction sig;
sig.sa_handler = stopall;
sigemptyset(&sig.sa_mask);
//sigaddset(&new.sa_mask, SIGINT);
//sigaddset(&new.sa_mask, SIGALRM);
sig.sa_flags = 0;
//sigaction(SIGINT, NULL, &old);
//if (old_action.sa_handler != SIG_IGN) {
sigaction(SIGINT, &sig, NULL);
sigaction(SIGALRM, &sig, NULL);
# ifdef DEBUG
printf("SIGINT and SIGALRM armed.\n");
# endif
}