.
This commit is contained in:
26
bac2/os/chap1/ex4.c
Normal file
26
bac2/os/chap1/ex4.c
Normal file
@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user