Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <signal.h>
- /*
- * Gracefully exits when Ctrl+C is pressed.
- */
- void sigint_handler(int signum) {
- exit(0);
- }
- struct sigaction act;
- memset((void *)&act, 0, sizeof(act));
- act.sa_handler = sigint_handler;
- if (sigaction(SIGINT, &act, NULL) == -1) {
- perror("sigaction");
- exit(-1);
- }
Add Comment
Please, Sign In to add comment