> It seems that Ctrl-C triggers a �threadWaitRead� (I have a 
> sigInt-handler
> installed, which gets triggered, too).
> 
> If I use
> >   _ <- installHandler sigINT (Catch (putStrLn "test" >> 
> putMVar haltMVar () ))
>  Nothing -- Ctrl-C
> >   muxCh <- newChan
> >   forkIO (takeMVar hvar >> writeChan muxCh Quit)
> >   forkIO (threadWaitRead (fdToInt fd) >> writeChan mux Msg)
> >   msg <- readChan mux
> 
> the threadWaitRead will be triggered first.

Thanks for the report - this is indeed a bug.  I've attached a patch below.

Cheers,
        Simon

*** Select.c    2000/03/20 09:42:50     1.10
--- Select.c    2000/03/23 12:02:38     1.11
***************
*** 1,5 ****
  /*
----------------------------------------------------------------------------
-
!  * $Id: Select.c,v 1.10 2000/03/20 09:42:50 andy Exp $
   *
   * (c) The GHC Team 1995-1999
   *
--- 1,5 ----
  /*
----------------------------------------------------------------------------
-
!  * $Id: Select.c,v 1.11 2000/03/23 12:02:38 simonmar Exp $
   *
   * (c) The GHC Team 1995-1999
   *
***************
*** 52,57 ****
--- 52,58 ----
      int numFound;
      nat min, delta;
      int maxfd = -1;
+     rtsBool select_succeeded = rtsTrue;
     
      struct timeval tv;
  #ifndef linux_TARGET_OS
***************
*** 165,170 ****
--- 166,173 ----
        if (signals_pending()) {
          RELEASE_LOCK(&sched_mutex);
          start_signal_handlers();
+         /* Don't wake up any other threads that were waiting on I/O */
+         select_succeeded = rtsFalse;
          break;
        }
  
***************
*** 173,178 ****
--- 176,182 ----
         */
        if (run_queue_hd != END_TSO_QUEUE) {
          RELEASE_LOCK(&sched_mutex);
+         select_succeeded = rtsFalse;
          break;
        }
  
***************
*** 209,224 ****
        next = tso->link;
        switch (tso->why_blocked) {
        case BlockedOnRead:
!         ready = FD_ISSET(tso->block_info.fd, &rfd);
          break;
  
        case BlockedOnWrite:
!         ready = FD_ISSET(tso->block_info.fd, &wfd);
          break;
  
        case BlockedOnDelay:
          {
-           int candidate; /* signed int is intentional */
  #if defined(HAVE_SETITIMER)
            if (tso->block_info.delay > delta) {
              tso->block_info.delay -= delta;
--- 213,227 ----
        next = tso->link;
        switch (tso->why_blocked) {
        case BlockedOnRead:
!         ready = select_succeeded && FD_ISSET(tso->block_info.fd, &rfd);
          break;
  
        case BlockedOnWrite:
!         ready = select_succeeded && FD_ISSET(tso->block_info.fd, &wfd);
          break;
  
        case BlockedOnDelay:
          {
  #if defined(HAVE_SETITIMER)
            if (tso->block_info.delay > delta) {
              tso->block_info.delay -= delta;
***************
*** 228,233 ****
--- 231,237 ----
              ready = 1;
            }
  #else
+           int candidate; /* signed int is intentional */
            candidate = tso->block_info.target - getourtimeofday();
            if (candidate < 0) {
              candidate = 0;

Reply via email to