Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <dirent.h>
- #include <file.h>
- #include <string.h>
- #include <sys/stat.h>
- #include <stdbool.h>
- #include <wait.h>
- #define SIGLIMIT 5
- int flag = true;
- void handlerSIGINT(int sig) {
- static int counter = 0;
- if (counter > SIGLIMIT) {
- printf("SIG counter %d", counter);
- flag = false;
- }
- }
- int main() {
- struct sigaction s;
- s.sa_handler = handlerSIGINT;
- s.sa_flags = 0;
- sigemptyset(&s.sa_mask);
- sigaddset(&s.sa_mask, SIGQUIT);
- sigaddset(&s.sa_mask, SIGINT);
- sigaction(SIGINT, &s, NULL);
- for (int i = 0; flag; ++i) {
- sigsuspend(&s.sa_mask);
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement