mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 23:02:01 +00:00
Initial Windows autoupdater support: the ioq3 internal bits.
This is just the piece that will launch the autoupdater; the autoupdater itself will be a separate commit.
This commit is contained in:
parent
67b0cccc75
commit
02b116aae0
1 changed files with 21 additions and 1 deletions
|
@ -31,9 +31,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifdef USE_AUTOUPDATER
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DEDICATED
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
|
@ -669,6 +674,20 @@ int main( int argc, char **argv )
|
|||
#error The build system should have defined AUTOUPDATER_BIN
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
/* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */
|
||||
PROCESS_INFORMATION procinfo;
|
||||
char cmdline[128];
|
||||
Com_sprintf(cmdline, sizeof (cmdline), AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
|
||||
if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &procinfo))
|
||||
{
|
||||
/* close handles now so child cleans up immediately if nothing to do */
|
||||
CloseHandle(procinfo.hProcess);
|
||||
CloseHandle(procinfo.hThread);
|
||||
}
|
||||
}
|
||||
#else
|
||||
int updater_pipes[2];
|
||||
if (pipe(updater_pipes) == 0)
|
||||
{
|
||||
|
@ -702,6 +721,7 @@ int main( int argc, char **argv )
|
|||
close(updater_pipes[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue