diff --git a/Server/Components/Console/console_impl.hpp b/Server/Components/Console/console_impl.hpp index a993197a8..c8a782143 100644 --- a/Server/Components/Console/console_impl.hpp +++ b/Server/Components/Console/console_impl.hpp @@ -65,6 +65,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler String cmd; ThreadProcData* threadData; std::thread cinThread; + std::thread::native_handle_type nativeThreadHandle; struct PlayerRconCommandHandler : public SingleNetworkInEventHandler { @@ -212,7 +213,11 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler threadData = new ThreadProcData { true, this }; cinThread = std::thread(ThreadProc, threadData); + nativeThreadHandle = cinThread.native_handle(); + +#ifndef WIN32 cinThread.detach(); +#endif } void onReady() override @@ -257,10 +262,16 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler if (threadData) { threadData->valid = false; + +#ifdef WIN32 if (cinThread.joinable()) { cinThread.join(); } +#else + pthread_cancel(nativeThreadHandle); +#endif + delete threadData; threadData = nullptr; }