feat: update structure
This commit is contained in:
21
cs2106/lectures/l5/4.c
Normal file
21
cs2106/lectures/l5/4.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void myOwnHandler(int signo) {
|
||||
if (signo == SIGSEGV) {
|
||||
printf("Memory Access blows up!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int *ip = NULL;
|
||||
|
||||
if (signal(SIGSEGV, myOwnHandler) == SIG_ERR)
|
||||
printf("Failed to register handler\n");
|
||||
|
||||
*ip = 123;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user