Guard autoupdater more completely

This commit is contained in:
Tim Angus committed 2025-11-06 12:56:13 +00:00
1 parent 76043c78b9
commit a9a6ccb103
3 files changed
+20 -21

No files matched your search

+14 -20
View File
@@ -17,28 +17,24 @@ is licensed under the GPLv2. Do not mingle code, please!
# include <stdio.h>
# include <string.h>
#endif
void Sys_LaunchAutoupdater(int argc, char **argv)
{
#ifdef USE_AUTOUPDATER
#ifdef _WIN32
{
/* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */
PROCESS_INFORMATION procinfo;
STARTUPINFO startinfo;
char cmdline[128];
memset(&procinfo, '\0', sizeof (procinfo));
memset(&startinfo, '\0', sizeof (startinfo));
startinfo.cb = sizeof (startinfo);
sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
/* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */
PROCESS_INFORMATION procinfo;
STARTUPINFO startinfo;
char cmdline[128];
memset(&procinfo, '\0', sizeof (procinfo));
memset(&startinfo, '\0', sizeof (startinfo));
startinfo.cb = sizeof (startinfo);
sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
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 */
CloseHandle(procinfo.hProcess);
CloseHandle(procinfo.hThread);
}
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 */
CloseHandle(procinfo.hProcess);
CloseHandle(procinfo.hThread);
}
#else
int updater_pipes[2];
@@ -79,8 +75,6 @@ void Sys_LaunchAutoupdater(int argc, char **argv)
}
}
#endif
#endif
(void) argc; (void) argv; /* possibly unused. Pacify compilers. */
}
#endif /* USE_AUTOUPDATER */