Guard autoupdater more completely

This commit is contained in:
Tim Angus 2025-11-02 14:03:42 +00:00
parent 76043c78b9
commit a9a6ccb103
3 changed files with 20 additions and 21 deletions

View File

@ -17,28 +17,24 @@ is licensed under the GPLv2. Do not mingle code, please!
# include <stdio.h> # include <stdio.h>
# include <string.h> # include <string.h>
#endif
void Sys_LaunchAutoupdater(int argc, char **argv) void Sys_LaunchAutoupdater(int argc, char **argv)
{ {
#ifdef USE_AUTOUPDATER
#ifdef _WIN32 #ifdef _WIN32
{ /* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */
/* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */ PROCESS_INFORMATION procinfo;
PROCESS_INFORMATION procinfo; STARTUPINFO startinfo;
STARTUPINFO startinfo; char cmdline[128];
char cmdline[128]; memset(&procinfo, '\0', sizeof (procinfo));
memset(&procinfo, '\0', sizeof (procinfo)); memset(&startinfo, '\0', sizeof (startinfo));
memset(&startinfo, '\0', sizeof (startinfo)); startinfo.cb = sizeof (startinfo);
startinfo.cb = sizeof (startinfo); sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startinfo, &procinfo)) if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startinfo, &procinfo))
{ {
/* close handles now so child cleans up immediately if nothing to do */ /* close handles now so child cleans up immediately if nothing to do */
CloseHandle(procinfo.hProcess); CloseHandle(procinfo.hProcess);
CloseHandle(procinfo.hThread); CloseHandle(procinfo.hThread);
}
} }
#else #else
int updater_pipes[2]; int updater_pipes[2];
@ -79,8 +75,6 @@ void Sys_LaunchAutoupdater(int argc, char **argv)
} }
} }
#endif #endif
#endif
(void) argc; (void) argv; /* possibly unused. Pacify compilers. */
} }
#endif /* USE_AUTOUPDATER */

View File

@ -73,3 +73,7 @@ qboolean Sys_OpenFolderInPlatformFileManager( const char *path );
#ifdef PROTOCOL_HANDLER #ifdef PROTOCOL_HANDLER
char *Sys_ParseProtocolUri( const char *uri ); char *Sys_ParseProtocolUri( const char *uri );
#endif #endif
#ifdef USE_AUTOUPDATER
void Sys_LaunchAutoupdater(int argc, char **argv);
#endif

View File

@ -790,8 +790,9 @@ int main( int argc, char **argv )
char *protocolCommand = NULL; char *protocolCommand = NULL;
#endif #endif
extern void Sys_LaunchAutoupdater(int argc, char **argv); #ifdef USE_AUTOUPDATER
Sys_LaunchAutoupdater(argc, argv); Sys_LaunchAutoupdater(argc, argv);
#endif
#ifndef DEDICATED #ifndef DEDICATED
// SDL version check // SDL version check