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
- volatile sig_atomic_t compteur;
- void handlerSIGINT(int sig) {
- compteur++;
- printf("Compteur = %d\n",compteur);
- }
- int main() {
- compteur = 0;
- struct sigaction s;
- sigset_t masque;
- //Init
- sigemptyset(&s.sa_mask);
- s.sa_handler = handlerSIGINT;
- s.sa_flags = 0;
- // sigaddset(&s.sa_mask, SIGQUIT);
- //Redirige le signal
- sigaction(SIGINT, &s, NULL);
- //attend 5 interuptions
- sigemptyset(&masque);
- while (compteur < 5)
- sigsuspend(&masque);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement