Created
June 20, 2016 15:26
-
-
Save alex-eg/98548eccaa54b4297b01511ea0a15e03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
| int i = 0; | |
| jmp_buf jump_buffer; | |
| void sigsegv_handler(int signum) { | |
| printf(" Ignoring SIGSEGV is a bad idea\n"); | |
| longjmp(jump_buffer, 1); | |
| } | |
| int main(void) { | |
| signal(SIGSEGV, sigsegv_handler); // huh | |
| int *p = &i; | |
| for(; i < 1000; i ++) { | |
| if (sigsetjmp(jump_buffer, 1) == 0) { | |
| printf("%d:", i); | |
| printf(" %lp", i + p); | |
| printf(" %d\n", *(i + p)); | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment