cours_progra/bac2/os/chap1/ex4.c

27 lines
438 B
C
Raw Normal View History

2023-10-18 20:27:40 +02:00
#include <signal.h>
#include <stdio.h>
typedef struct sigaction SIGS;
void handler(int sig, siginfo_t* info, void* context){
if(sig == SIGFPE){
printf("Division par zero... rip in peperoni...\n");
exit(1);
}
}
int main(int argc, char *argv[])
{
SIGS event = {
.sa_flags = SA_SIGINFO,
.sa_sigaction = handler
};
sigaction(SIGFPE, &event, NULL);
printf("I want to break free... \n");
printf("%d\n", 1/0);
return 0;
}