Advertisement
diegoaguilar

alarm

Feb 27th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<sys/types.h>
  2. #include<sys/wait.h>
  3. #include<sys/stat.h>
  4. #include<fcntl.h>
  5. #include<unistd.h>
  6. #include<stdio.h>
  7. #include<stdlib.h>
  8. #include<signal.h>
  9.  
  10. void manejador()
  11. {
  12. printf("\nHan pasado 3 segundos, tío");   
  13. }
  14.  
  15. int main ()
  16. {
  17.  
  18. struct sigaction act;
  19. act.sa_handler=manejador;
  20. sigemptyset(&act.sa_mask);
  21. sigaddset(&act.sa_mask, SIGINT);
  22. act.sa_flags=0;
  23. sigaction(SIGALRM, &act, NULL);
  24.  
  25. for ( ; ; )
  26. {
  27.     alarm(3);
  28.     pause();
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement