This commit is contained in:
Debucquoy
2023-10-18 20:27:40 +02:00
parent 4de4dcf2c2
commit b0f02b0d5d
29 changed files with 700 additions and 2 deletions

26
bac2/os/chap1/ex4.c Normal file
View 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;
}