Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <signal.h>
  4.  
  5. #define RING '\a'
  6.  
  7. int count = 0;
  8.  
  9. void processSignal(int Signal)
  10. {
  11. if (Signal == SIGQUIT)//дамп памяти
  12. {
  13. printf("Count of DELETE tapping: %d\n", count);
  14. exit(EXIT_SUCCESS);
  15. }
  16.  
  17. printf("%c\n", RING);
  18. count++;
  19. }
  20. int main()
  21. {
  22. if (sigset(SIGINT, processSignal) == SIG_ERR)//небезопасен для многопоточных, устарел
  23. {
  24. perror("Signal SIGINT setting error");
  25. exit(EXIT_FAILURE);
  26. }
  27. if (signal(SIGQUIT, processSignal) == SIG_ERR)
  28. {
  29. perror("Signal SIGQUIT setting error");
  30. exit(EXIT_FAILURE);
  31. }
  32. for (;;);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement