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

@ -9,6 +9,7 @@ Manager::Manager()
did_process = false;
next_beat = 0;
terminating = false;
}
Manager::~Manager()
@ -21,6 +22,8 @@ void Manager::Terminate()
{
DBG_LOG(DBG_THREADING, "Terminating thread manager ...");
terminating = true;
// First process remaining thread output for the message threads.
do Process(); while ( did_process );
@ -37,6 +40,16 @@ void Manager::Terminate()
all_threads.clear();
msg_threads.clear();
terminating = false;
}
void Manager::KillThreads()
{
DBG_LOG(DBG_THREADING, "Killing threads ...");
for ( all_thread_list::iterator i = all_threads.begin(); i != all_threads.end(); i++ )
(*i)->Kill();
}
void Manager::AddThread(BasicThread* thread)