Signal Handlers - Possible Solution: Flag finally, we have a safe signal handler volatile sig_atomic_t quit = 0; void sigterm(int sig) { quit = 1; } ok, there's still signal races... but that's another story :)