Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Task 4
- #include <stdio.h>
- #include <time.h>
- #include <signal.h>
- volatile time_t sigtime = 0;
- int count = 0;
- void handler(int sig) {
- printf("SIGINT: Count=%d\n", ++count);
- time(&sigtime);
- }
- int main(int argc, const char *argv[]) {
- time_t last = 0;
- signal(SIGINT, handler);
- printf("Start\n");
- sigtime = time(NULL);
- while(time(NULL) - sigtime < 2)
- sleep(1);
- printf("Done\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement