Reworking forceful thread termination.

Ctrl-C now kills a thread even if it hangs at termination. And readded
a (rather long) timeout to kill threads automatically that don't
shutdown.
This commit is contained in:
Robin Sommer 2012-07-17 19:36:30 -07:00
parent e90918aa50
commit 490859cfef
6 changed files with 50 additions and 12 deletions

View file

@ -125,7 +125,7 @@ void BasicThread::Join()
DBG_LOG(DBG_THREADING, "Joining thread %s ...", name.c_str());
if ( pthread_join(pthread, 0) != 0 )
if ( pthread && pthread_join(pthread, 0) != 0 )
reporter->FatalError("Failure joining thread %s", name.c_str());
DBG_LOG(DBG_THREADING, "Done with thread %s", name.c_str());
@ -135,13 +135,13 @@ void BasicThread::Join()
void BasicThread::Kill()
{
terminating = true;
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);
pthread = 0;
pthread_kill(pthread, SIGTERM);
}
void* BasicThread::launcher(void *arg)