Here's my code:
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
jmp_buf buf;
void handler(int s);
int main(int argc, char **argv) {
signal(SIGINT, handler);
if (setjmp(buf)) {
printf("back again!\n");
return 0;
} else {
printf("first here.\n");
}
for (;;) {}
}
void handler(int s) {
longjmp(buf, 1);
}
I compile it under VS 2012 on Windows 8 64bit. Every time I press Control+C, the program doesn't reboot as expected but stops working. Could anybody help me?