I need a clarification on sigsuspend topic. I have a simplified example

sigset_t mask, oldmask;
sigemptyset (&mask);
sigaddset (&mask, SIGRTMIN+1);
sigprocmask (SIG_BLOCK, &mask, &oldmask);

sigsuspend(&oldmask);

sigprocmask (SIG_UNBLOCK, &mask, NULL);

Here is how I understand this:

  • sigemptyset clears a list of signals (mask) - because it is initialized with currently blocked signals (?)
  • sigaddset adds SIGRTMIN+1 to mask
  • sigprocmask sets all signals in mask+oldmask to be blocked
  • sigsuspend(&oldmask) suspends thread execution till one of the blocked signals arrives ? Shouldn't there be sigsuspend(&mask) if I want to block SIGRTMIN+1?

    Secondly, let's suppose I have such sigsuspend in a loop and there arrived a few SIGRTMIN+1 signals. Will such loop continue for each signal ? in some kind of queue?

    while(1){
        sigsuspend(&oldmask)
        printf("recieved signal");
    }
    

    so that for each signal I have 'recieved signal' printed?

  • Edit
    Report