1
0
Fork 0

Fix crash after attempting to kill a non-running thread (#3504)

Fixes #3221
This commit is contained in:
Fabian Stein 2017-01-01 22:43:24 +01:00 committed by Mattes D
parent d4353f8084
commit ad476e1cf9
1 changed files with 7 additions and 4 deletions

View File

@ -304,11 +304,14 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
m_InputThread.join();
}
#else
if (pthread_kill(m_InputThread.native_handle(), SIGKILL) != 0)
if (m_InputThread.get_id() != std::thread::id())
{
LOGWARN("Couldn't notify the input thread; the server will hang before shutdown!");
m_TerminateEventRaised = true;
m_InputThread.detach();
if (pthread_kill(m_InputThread.native_handle(), SIGKILL) != 0)
{
LOGWARN("Couldn't notify the input thread; the server will hang before shutdown!");
m_TerminateEventRaised = true;
m_InputThread.detach();
}
}
#endif