From f25b6b47633fdb95526776e9af3e83d5b6eefebf Mon Sep 17 00:00:00 2001 From: "E. Becker" <147226263+TanF12@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:44:51 -0300 Subject: [PATCH] Fix Linux server deadlock on shutdown without TTY --- Server/Components/Console/console_impl.hpp | 9 +++++++-- Server/Components/Pawn/Plugin/Plugin.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Server/Components/Console/console_impl.hpp b/Server/Components/Console/console_impl.hpp index 60c38c88a..474a03377 100644 --- a/Server/Components/Console/console_impl.hpp +++ b/Server/Components/Console/console_impl.hpp @@ -56,6 +56,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler { std::atomic_bool valid; ConsoleComponent* component; + std::atomic_bool isRunning; }; ICore* core = nullptr; @@ -211,7 +212,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler NetCode::Packet::PlayerRconCommand::addEventHandler(*core, &playerRconCommandHandler); - threadData = new ThreadProcData { true, this }; + threadData = new ThreadProcData { true, this, true }; cinThread = std::thread(ThreadProc, threadData); nativeThreadHandle = cinThread.native_handle(); cinThread.detach(); @@ -249,6 +250,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler } else { + threadData->isRunning = false; return; } } @@ -266,7 +268,10 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler cinThread.join(); } #else - pthread_cancel(nativeThreadHandle); + if (threadData->isRunning) + { + pthread_cancel(nativeThreadHandle); + } #endif delete threadData; diff --git a/Server/Components/Pawn/Plugin/Plugin.cpp b/Server/Components/Pawn/Plugin/Plugin.cpp index 0d6278462..4f87fcfc8 100644 --- a/Server/Components/Pawn/Plugin/Plugin.cpp +++ b/Server/Components/Pawn/Plugin/Plugin.cpp @@ -7,6 +7,7 @@ */ #include "Plugin.h" +#include #include "../Manager/Manager.hpp" #ifdef WIN32