From 3a4cf34fa9b73e762c9a4c58f33aed7bd32bcc16 Mon Sep 17 00:00:00 2001 From: iAmir Date: Mon, 20 Oct 2025 12:27:18 +0330 Subject: [PATCH] fix sdtin lock from getline when shutting down --- Server/Components/Console/console_impl.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; }