Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <execinfo.h>
- #include <signal.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ucontext.h>
- #include <unistd.h>
- #include <sys/mman.h>
- int err=0;
- void handler(int sig, siginfo_t *info, void *uncontext ){
- // char buff[104];
- // snprintf(buff,100,"%d signal number: %d, An errno value: %d, Signal value: %d.\n",sig, (*info).si_signo, (*info).si_errno, (*info).si_code);
- // write(2,buff,100);
- err++;
- printf("Error %d\n",err);
- }
- int main(void) {
- struct sigaction mysig_act;
- mysig_act.sa_flags = SA_SIGINFO;
- mysig_act.sa_sigaction = &handler;
- sigaction(SIGSEGV,&mysig_act,NULL);
- long *addr = mmap(NULL,44,PROT_NONE,MAP_PRIVATE,0,0);
- munmap(addr,44);
- (*addr) = 4;
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement