[project @ 2003-10-01 10:49:07 by wolfgang]
[ghc-hetmet.git] / ghc / rts / Select.c
index e698d8e..d7e6ffc 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Select.c,v 1.25 2003/02/22 04:51:57 sof Exp $
+ * $Id: Select.c,v 1.30 2003/10/01 10:49:09 wolfgang Exp $
  *
  * (c) The GHC Team 1995-2002
  *
 /* #include "PosixSource.h" */
 
 #include "Rts.h"
-#ifndef mingw32_TARGET_OS
-/* to the end */
-
 #include "Schedule.h"
 #include "RtsUtils.h"
 #include "RtsFlags.h"
 #include "Timer.h"
+#include "Itimer.h"
 #include "Signals.h"
 #include "Capability.h"
 
 #include <errno.h>
 #include <string.h>
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 /* last timestamp */
 nat timestamp = 0;
 
@@ -234,12 +236,14 @@ awaitEvent(rtsBool wait)
           * we could block for a long time before the signal is
           * serviced.
           */
+#if defined(RTS_USER_SIGNALS)
          if (signals_pending()) {
              RELEASE_LOCK(&sched_mutex); /* ToDo: kill */
              startSignalHandlers();
              ACQUIRE_LOCK(&sched_mutex);
              return; /* still hold the lock */
          }
+#endif
 
          /* we were interrupted, return to the scheduler immediately.
           */
@@ -347,6 +351,20 @@ wakeBlockedWorkerThread()
        workerWakeupPending = rtsTrue;
     }
 }
-#endif
 
-#endif /* !mingw_TARGET_OS */
+/* resetWorkerWakeupPipeAfterFork
+ *
+ * To be called right after a fork().
+ * After the fork(), the worker wakeup pipe will be shared
+ * with the parent process, and that's something we don't want.
+ */
+void
+resetWorkerWakeupPipeAfterFork()
+{
+    if(workerWakeupInited) {
+       close(workerWakeupPipe[0]);
+       close(workerWakeupPipe[1]);
+    }
+    workerWakeupInited = rtsFalse;
+}
+#endif