Cygwin 1.7: signal handler not invoked (regression from 1.5)

Roberto Bagnara bagnara@cs.unipr.it
Mon Oct 6 19:01:00 GMT 2008


Hi there,

the following shows a problem in Cygwin 1.7 that is
not present in Cygwin 1.5:

roberto@sissi /tmp
$ cat bug.c
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <stdio.h>

volatile int alarm_called = 0;

void alarm(int sig) {
   alarm_called = 1;
}

int main() {
   unsigned long i;
   struct itimerval it;

   it.it_interval.tv_sec = 0;
   it.it_interval.tv_usec = 0;

   /* 100,000 microseconds. */
   it.it_value = (struct timeval) { 0, 100000 };
   signal(SIGALRM, alarm);

   setitimer(ITIMER_REAL, &it, (struct itimerval *) 0);

   for (i = 0; i <= 2000000000; ++i)
     if (alarm_called)
       break;

   if (alarm_called)
     printf("alarm() called\n");
   else
     printf("alarm() NOT called\n");

   return 0;
}


roberto@sissi /tmp
$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

roberto@sissi /tmp
$ gcc bug.c

roberto@sissi /tmp
$ time ./a.exe
alarm() NOT called

real    0m7.203s
user    0m7.201s
sys     0m0.015s

roberto@sissi /tmp
$

As you see, the alarm() function is not invoked as it should
(and as it is in Cygwin 1.5).
All the best,

      Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list