[project @ 2002-05-10 22:02:02 by sof]
authorsof <unknown>
Fri, 10 May 2002 22:02:02 +0000 (22:02 +0000)
committersof <unknown>
Fri, 10 May 2002 22:02:02 +0000 (22:02 +0000)
stopTaskManager(): no seppuku, please.

ghc/rts/Task.c

index 4086127..bc701b0 100644 (file)
@@ -46,7 +46,6 @@ static nat maxTasks;
 /* number of tasks currently created */
 static nat taskCount; 
 
-
 #if defined(SMP)
 void
 startTaskManager( nat maxCount, void (*taskStart)(void) )
@@ -100,6 +99,7 @@ void
 stopTaskManager ()
 {
   nat i;
+  OSThreadId tid = osThreadId();
 
   /* Don't want to use pthread_cancel, since we'd have to install
    * these silly exception handlers (pthread_cleanup_{push,pop}) around
@@ -120,9 +120,12 @@ stopTaskManager ()
 #endif
 
   /* Send 'em all a SIGHUP.  That should shut 'em up. */
-  await_death = maxCount;
+  await_death = maxCount - 1;
   for (i = 0; i < maxCount; i++) {
-    pthread_kill(taskTable[i].id,SIGTERM);
+    /* don't cancel the thread running this piece of code. */
+    if ( taskTable[i].id != tid ) {
+      pthread_kill(taskTable[i].id,SIGTERM);
+    }
   }
   while (await_death > 0) {
     sched_yield();
@@ -183,6 +186,8 @@ startTask ( void (*taskStart)(void) )
   return;
 }
 
+
+
 void
 stopTaskManager ()
 {