#include #include #include #include static jmp_buf env; void handler(int sig) { longjmp(env, 1); puts("longjmp failed"); exit(-2); } int main(void) { int i; for (i = 0; i < 2; i++) { volatile char *p = NULL; signal(SIGSEGV, handler); if (setjmp(env) == 0) { *p; puts("SEGV failed"); exit(-1); } else printf("Partial success: %d\n", i); } puts("PASS"); return 0; }