27 lines
438 B
C
27 lines
438 B
C
|
#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;
|
||
|
}
|