Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<signal.h>
- #include<unistd.h>
- #include<errno.h>
- volatile static sig_atomic_t n = 0;
- const char msg[] = "Try again, please.\n";
- void handle(){
- int save_errno = errno;
- signal(SIGINT, handle);
- n++;
- write(1, msg, sizeof(msg)-1);
- errno = save_errno;
- }
- int main(){
- signal(SIGINT, handle);
- while(n < 25)
- sleep(1);
- return 0;
- }
- ~
- ~
- ~
- ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement