Improved signal handling.

Sending SIGTERM triggers a normal shutdown of all threads that waits
until they have processed their remaining data. However, sending a 2nd
SIGTERM while waiting for them to finish will immediately kill them
all.
This commit is contained in:
Robin Sommer 2012-02-03 03:03:38 -08:00
parent ffb4094d36
commit 4879cb7b0d
5 changed files with 56 additions and 0 deletions

View file

@ -113,6 +113,17 @@ void BasicThread::Join()
pthread = 0;
}
void BasicThread::Kill()
{
if ( ! (started && pthread) )
return;
// I believe this is safe to call from a signal handler ... Not error
// checking so that killing doesn't bail out if we have already
// terminated.
pthread_kill(pthread, SIGKILL);
}
void* BasicThread::launcher(void *arg)
{
BasicThread* thread = (BasicThread *)arg;