From 0cf466769fffa7d8cc5feeb908a641c40728796b Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 10 May 2002 22:02:02 +0000 Subject: [PATCH] [project @ 2002-05-10 22:02:02 by sof] stopTaskManager(): no seppuku, please. --- ghc/rts/Task.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ghc/rts/Task.c b/ghc/rts/Task.c index 4086127..bc701b0 100644 --- a/ghc/rts/Task.c +++ b/ghc/rts/Task.c @@ -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 () { -- 1.7.10.4