From ad476e1cf9c0bc5d6daf9286e264e37744332fbf Mon Sep 17 00:00:00 2001 From: Fabian Stein Date: Sun, 1 Jan 2017 22:43:24 +0100 Subject: Fix crash after attempting to kill a non-running thread (#3504) Fixes #3221 --- src/Root.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Root.cpp b/src/Root.cpp index 2a00c5cfa..3d3930975 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -304,11 +304,14 @@ void cRoot::Start(std::unique_ptr 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 -- cgit v1.2.3