delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/03/10/15:42:38

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
To: cygwin-developers AT cygwin DOT com
Subject: Blocked signals are incorrectly queued/dequeued.
Mime-Version: 1.0 (generated by tm-edit 7.106)
From: Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
Date: 11 Mar 2001 05:41:47 +0900
Message-ID: <s1szoetpd9w.fsf@jaist.ac.jp>
Lines: 109
X-Mailer: Gnus v5.3/Emacs 19.34

--Multipart_Sun_Mar_11_05:41:47_2001-1
Content-Type: text/plain; charset=US-ASCII

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.


--Multipart_Sun_Mar_11_05:41:47_2001-1
Content-Type: text/plain; charset=US-ASCII

#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);
  }
}

--Multipart_Sun_Mar_11_05:41:47_2001-1
Content-Type: text/plain; charset=US-ASCII

____
  | AIST      Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
  | HOKURIKU  School of Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology

--Multipart_Sun_Mar_11_05:41:47_2001-1--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019