Created
February 12, 2016 16:29
-
-
Save robbmanes/4e19eaa84e29242c30fa to your computer and use it in GitHub Desktop.
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 <stdlib.h> | |
#include <signal.h> | |
#include <unistd.h> | |
#define IGNORE_ALL_SIGNALS 1 | |
void signal_loop(int sig); | |
int main(int argc, char **argv) | |
{ | |
#ifdef IGNORE_ALL_SIGNALS | |
sigset_t mask; | |
sigfillset(&mask); | |
sigprocmask(SIG_SETMASK, &mask, NULL); | |
#else | |
signal(SIGQUIT, signal_loop); | |
#endif | |
printf("Entering loop waiting for -3 signal...\n"); | |
for(;;) | |
{ | |
sleep(1); | |
} | |
return 0; | |
} | |
void signal_loop(int sig) | |
{ | |
printf("Caught -3 SIQQUIT, press enter to continue.\n"); | |
getchar(); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment