This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Blocked signals are incorrectly queued/dequeued.


The test program attached below shows the following behavior on
NT4 Sp6a and the latest Cygwin DLL.
1. Blocked signals are queued.
2. One of them are dequeued when the block is released.
3. Others are dequeued two by two when other signals are triggered.

The following illustrates the output of the program.
HANDLER1
SIGUSR1
(sleep 5sec.)
HANDLER1
SIGUSR1
HANDLER2
SIGUSR2
HANDLER1
SIGUSR1
(sleep 5sec.)
HANDLER1
SIGUSR1
HANDLER2
SIGUSR2
HANDLER1
SIGUSR1
(sleep 5sec.)
...

This behavior isn't compatible with typical UNIX. I believe the
Cygwin DLL shouldn't queue blocked signals and should deliver
only one of them.

#include<signal.h>
#include<unistd.h>
#include<stdio.h>
#include<errno.h>

void
recvsig1(int sig)
{
  puts("HANDLER1");
  switch(sig)
    {
    case SIGUSR1:
      puts("SIGUSR1");
      break;
    case SIGUSR2:
      puts("SIGUSR2");
      break;
    default:
      puts("UNKNOWN");
      break;
  }
}

void
recvsig2(int sig)
{
  puts("HANDLER2");
  switch(sig)
    {
    case SIGUSR1:
      puts("SIGUSR1");
      break;
    case SIGUSR2:
      puts("SIGUSR2");
      break;
    default:
      puts("UNKNOWN");
      break;
  }
}

int
main()
{
  int i;
  int pid = getpid();
  static sigset_t unblock,block,old;

  signal (SIGUSR1,recvsig1);
  signal (SIGUSR2,recvsig2);
  sigfillset (&block);
  sigemptyset (&unblock);
  sigprocmask (SIG_SETMASK,&block,&old);
  for(i = 0; i < 5; i++)
    kill(pid,SIGUSR1);
  sigprocmask(SIG_SETMASK,&unblock,&old);
  sleep(5);
  for(i=0; i < 5; i++) {
    kill(pid,SIGUSR2);
    sleep(5);
  }
}
____
  | AIST      Kazuhiro Fujieda <fujieda@jaist.ac.jp>
  | HOKURIKU  School of Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]