Created
March 21, 2017 08:55
-
-
Save dariost/deab862348d46028662e1dad969ce155 to your computer and use it in GitHub Desktop.
For implemented with SIGSEGV handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <signal.h> | |
#include <setjmp.h> | |
jmp_buf jump_buffer; | |
int count = 0; | |
void handler(int p) | |
{ | |
(void)p; | |
siglongjmp(jump_buffer, count++); | |
} | |
int main(int argc, char* argv[]) | |
{ | |
(void)argc; | |
(void)argv; | |
signal(SIGSEGV, handler); | |
int* lel = NULL; | |
if(!sigsetjmp(jump_buffer, 1)) | |
printf("%d\n", *lel); | |
printf("%d\n", count - 1); | |
if(count == 10) | |
return 0; | |
printf("%d\n", *lel); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment