[ioquake3] 65/136: Initial Windows autoupdater support: the ioq3 internal bits.

Simon McVittie smcv at debian.org
Thu Jun 15 09:09:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository ioquake3.

commit 02b116aae049349ee343a6fcc4a0b0d1a0911575
Author: Ryan C. Gordon <icculus at icculus.org>
Date:   Wed May 31 01:02:26 2017 -0400

    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.
---
 code/sys/sys_main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c
index e754304..81d5c97 100644
--- a/code/sys/sys_main.c
+++ b/code/sys/sys_main.c
@@ -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
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git



More information about the Pkg-games-commits mailing list