From 8b53b36b20aecd419de57e0edc9dc9c116cc0399 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 22 Dec 2025 12:53:39 +0100 Subject: [PATCH] fix: Exit code getting in forwarder not working --- main/forwarder/source/main.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main/forwarder/source/main.cpp b/main/forwarder/source/main.cpp index b5f6bf349..97781f5cb 100644 --- a/main/forwarder/source/main.cpp +++ b/main/forwarder/source/main.cpp @@ -126,17 +126,18 @@ int launchExecutable() { // Wait for the child process to exit ::WaitForSingleObject(pi.hProcess, INFINITE); - // Clean up - ::CloseHandle(pi.hProcess); - ::CloseHandle(pi.hThread); - ::CloseHandle(hChildStdoutRead); - + // Get the exit code of the child process DWORD exitCode = 0; - if (::GetExitCodeProcess(pi.hProcess, &exitCode)) { - return static_cast(exitCode); - } else { - return EXIT_FAILURE; + if (!::GetExitCodeProcess(pi.hProcess, &exitCode)) { + exitCode = EXIT_FAILURE; } + + // Clean up + ::CloseHandle(pi.hProcess); + ::CloseHandle(pi.hThread); + ::CloseHandle(hChildStdoutRead); + + return static_cast(exitCode); } int main() {