Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sigaction - why don't we have to reset the handler?
- #include <unistd.h>
- #include <stdio.h>
- #include <signal.h>
- void func(int sig)
- {
- printf("caught signal:%dn",sig);
- // Not needed to reset handler. Why?
- }
- int main()
- {
- struct sigaction sa;
- sa.sa_handler=(void*)func;
- sigaction(SIGRTMIN,&sa,NULL);
- kill(0,SIGRTMIN);
- kill(0,SIGRTMIN);
- kill(0,SIGRTMIN);
- }
- Output:
- [root@dhcppc0 signals]# ./a.out
- caught signal:34
- caught signal:34
- caught signal:34 (3 times signal caught by same handler without resetting handler)
Advertisement
Add Comment
Please, Sign In to add comment