Note that there are some explanatory texts on larger screens.

plurals
  1. POsigprocmask( ) blocking signals in UNIX
    primarykey
    data
    text
    <p>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.</p> <p>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. Please help. <strong>N.B: Please don't give links to answers of other questions on sigprocmask( ), i have seen them and they don't clarify my question.</strong></p> <pre><code>enter code here #include &lt;signal.h&gt; #include &lt;unistd.h&gt; #include &lt;stdio.h&gt; int main() { sigset_t old_set,new_set; sigemptyset(&amp;old_set); sigemptyset(&amp;new_set); if(sigaddset(&amp;old_set,SIGSEGV)==0) { printf("sigaddset successfully added for SIGSEGV\n"); } sigprocmask(SIG_BLOCK,&amp;old_set,NULL); // SIGSEGV signal is masked kill(0,SIGSEGV); //***************************************************************** if(sigaddset(&amp;new_set,SIGRTMIN)==0) { printf("sigaddset successfully added for SIGRTMIN\n"); } sigprocmask(SIG_BLOCK,&amp;new_set,&amp;old_set); // SIGRTMIN signal is masked kill(0,SIGSEGV); //****************** Unblock one signal at a time ****************** sigprocmask(SIG_UNBLOCK,&amp;new_set,&amp;old_set); // SIGRTMIN signal is unmasked sigprocmask(SIG_UNBLOCK,&amp;new_set,&amp;old_set); // SIGSEGV signal is unmasked </code></pre> <p>}</p> <pre><code>Output: [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,&amp;new_set,&amp;old_set); a second time) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload