From 6197dfdf6869c989029bd95ef8e0049b1e8eb8f0 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 24 Oct 2024 09:39:25 +0200 Subject: [PATCH 1/2] Update withlockfile.cpp Return the exit code of the underlying process --- withlockfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/withlockfile.cpp b/withlockfile.cpp index 72005f6..dfd8e5c 100644 --- a/withlockfile.cpp +++ b/withlockfile.cpp @@ -192,7 +192,7 @@ int main( int argc, char **argv ) throw Win32Error( "CloseHandle", ::GetLastError() ); } - return 0; + return exitCode; } catch ( const Win32Error &e ) { /* The MSDN documentation for FormatMessage says that the buf cannot * be larger than 64K bytes. From f5a757e8537f385ba129f58aa5bec245cfc12534 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 24 Oct 2024 09:41:55 +0200 Subject: [PATCH 2/2] Update withlockfile.cpp STARTUPINFO -> STARTUPINFOA --- withlockfile.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/withlockfile.cpp b/withlockfile.cpp index dfd8e5c..46573f1 100644 --- a/withlockfile.cpp +++ b/withlockfile.cpp @@ -127,10 +127,11 @@ int main( int argc, char **argv ) PROCESS_INFORMATION pi = { 0 }; - STARTUPINFO si = { sizeof( si ) }; - si.hStdError = ::GetStdHandle( STD_ERROR_HANDLE ); - si.hStdOutput = ::GetStdHandle( STD_OUTPUT_HANDLE ); - si.hStdInput = ::GetStdHandle( STD_INPUT_HANDLE ); + STARTUPINFOA sia = { sizeof(sia)}; + sia.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); + sia.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); + sia.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); + if ( ::CreateProcessA( executable.c_str(), const_cast( commandLine.c_str() ), @@ -140,7 +141,7 @@ int main( int argc, char **argv ) CREATE_SUSPENDED, NULL, NULL, - &si, + &sia, &pi ) == FALSE ) { throw Win32Error( "CreateProcessA", ::GetLastError() ); }