Guest User

Untitled

a guest
Jun 27th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. sigaction - why don't we have to reset the handler?
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <signal.h>
  5.  
  6. void func(int sig)
  7. {
  8. printf("caught signal:%dn",sig);
  9. // Not needed to reset handler. Why?
  10. }
  11.  
  12. int main()
  13. {
  14. struct sigaction sa;
  15.  
  16. sa.sa_handler=(void*)func;
  17. sigaction(SIGRTMIN,&sa,NULL);
  18. kill(0,SIGRTMIN);
  19. kill(0,SIGRTMIN);
  20. kill(0,SIGRTMIN);
  21. }
  22. Output:
  23. [root@dhcppc0 signals]# ./a.out
  24. caught signal:34
  25. caught signal:34
  26. caught signal:34 (3 times signal caught by same handler without resetting handler)
Advertisement
Add Comment
Please, Sign In to add comment