Results 1 to 2 of 2
Hi All, i have written a small piece of code. This code first blocks the {SIGSEGV}, then adds SIGRTMIN to the same set. So, my final signal set is, {SIGSEGV,SIGRTMIN}. ...
- 03-13-2011 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 34
[SOLVED] sigprocmask( ) blocking signals in UNIX
Hi All, i have written a small piece of code. This code first blocks the {SIGSEGV}, then adds SIGRTMIN to the same set. So, my final signal set is, {SIGSEGV,SIGRTMIN}. Thus, if i use SIG_UNBLOCK, as per my understanding, first SIGRTMIN should be unblocked, and then again if i invoke SIG_UNBLOCK, SIGSEGV should be unblocked.
That is, 1) {SIGSEGV,SIGRTMIN} 2) SIG_UNBLOCK = unblock SIGRTMIN, 3) Again invoke SIG_UNBLOCK = unblock SIGSEGV. I am giving the process a SIGRTMIN only, thus my second unblock should halt the process with SIGRTMIN. But it is not.
Output:Code:#include <signal.h> #include <unistd.h> #include <stdio.h> int main() { sigset_t old_set,new_set; sigemptyset(&old_set); sigemptyset(&new_set); if(sigaddset(&old_set,SIGSEGV)==0) { printf("sigaddset successfully added for SIGSEGV\n"); } sigprocmask(SIG_BLOCK,&old_set,NULL); // SIGSEGV signal is masked kill(0,SIGSEGV); //***************************************************************** if(sigaddset(&new_set,SIGRTMIN)==0) { printf("sigaddset successfully added for SIGRTMIN\n"); } sigprocmask(SIG_BLOCK,&new_set,&old_set); // SIGRTMIN signal is masked kill(0,SIGSEGV); //****************** Unblock one signal at a time ****************** sigprocmask(SIG_UNBLOCK,&new_set,&old_set); // SIGRTMIN signal is unmasked sigprocmask(SIG_UNBLOCK,&new_set,&old_set); // SIGSEGV signal is unmasked
Code:[root@dhcppc0 signals]# ./a.out sigaddset successfully added for SIGSEGV sigaddset successfully added for SIGRTMIN (Note:SIGSEGV is not received even after sigprocmask(SIG_UNBLOCK,&new_set,&old_set); a second time)
- 03-13-2011 #2Just Joined!
- Join Date
- Dec 2010
- Posts
- 34


