Guest User

Untitled

a guest
Jan 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <signal.h>
  3.  
  4. /*
  5. * Gracefully exits when Ctrl+C is pressed.
  6. */
  7. void sigint_handler(int signum) {
  8. exit(0);
  9. }
  10.  
  11. struct sigaction act;
  12. memset((void *)&act, 0, sizeof(act));
  13. act.sa_handler = sigint_handler;
  14. if (sigaction(SIGINT, &act, NULL) == -1) {
  15. perror("sigaction");
  16. exit(-1);
  17. }
Add Comment
Please, Sign In to add comment