From fdc3651992b38ed2b316f92ccf7406f2ac88c005 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 27 Oct 2021 09:25:56 -0500 Subject: [PATCH] proton: Return the real application return code on exit. CW-Bug-Id: #15930 --- proton | 15 +++++++++------ steam_helper/steam.cpp | 14 ++++++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/proton b/proton index 47d99f1b..8f58684e 100755 --- a/proton +++ b/proton @@ -1229,7 +1229,7 @@ class Session: def run_proc(self, args, local_env=None): if local_env is None: local_env = self.env - subprocess.call(args, env=local_env, stderr=self.log_file, stdout=self.log_file) + return subprocess.call(args, env=local_env, stderr=self.log_file, stdout=self.log_file) def run(self): if "PROTON_DUMP_DEBUG_COMMANDS" in self.env and nonzero(self.env["PROTON_DUMP_DEBUG_COMMANDS"]): @@ -1244,7 +1244,7 @@ class Session: else: remote_debug_proc = None - self.run_proc([g_proton.wine_bin, "steam"] + sys.argv[2:] + self.cmdlineappend) + rc = self.run_proc([g_proton.wine_bin, "steam"] + sys.argv[2:] + self.cmdlineappend) if remote_debug_proc: remote_debug_proc.kill() @@ -1255,6 +1255,8 @@ class Session: remote_debug_proc.terminate() remote_debug_proc.communicate() + return rc + if __name__ == "__main__": if not "STEAM_COMPAT_DATA_PATH" in os.environ: log("No compat data path?") @@ -1277,16 +1279,17 @@ if __name__ == "__main__": g_session.init_session(sys.argv[1] != "runinprefix") #determine mode + rc = 0 if sys.argv[1] == "run": #start target app - g_session.run() + rc = g_session.run() elif sys.argv[1] == "waitforexitandrun": #wait for wineserver to shut down g_session.run_proc([g_proton.wineserver_bin, "-w"]) #then run - g_session.run() + rc = g_session.run() elif sys.argv[1] == "runinprefix": - g_session.run_proc([g_proton.wine_bin] + sys.argv[2:]) + rc = g_session.run_proc([g_proton.wine_bin] + sys.argv[2:]) elif sys.argv[1] == "getcompatpath": #linux -> windows path path = subprocess.check_output([g_proton.wine_bin, "winepath", "-w", sys.argv[2]], env=g_session.env, stderr=g_session.log_file) @@ -1299,7 +1302,7 @@ if __name__ == "__main__": log("Need a verb.") sys.exit(1) - sys.exit(0) + sys.exit(rc) #pylint --disable=C0301,C0326,C0330,C0111,C0103,R0902,C1801,R0914,R0912,R0915 # vim: set syntax=python: diff --git a/steam_helper/steam.cpp b/steam_helper/steam.cpp index a2bdd126..e1f08357 100644 --- a/steam_helper/steam.cpp +++ b/steam_helper/steam.cpp @@ -1268,7 +1268,9 @@ int main(int argc, char *argv[]) HANDLE wait_handle = INVALID_HANDLE_VALUE; HANDLE event2 = INVALID_HANDLE_VALUE; HANDLE event = INVALID_HANDLE_VALUE; + HANDLE child = INVALID_HANDLE_VALUE; BOOL game_process = FALSE; + DWORD rc = 0; WINE_TRACE("\n"); @@ -1311,7 +1313,6 @@ int main(int argc, char *argv[]) if (argc > 1) { - HANDLE child; BOOL should_await; setup_vrpaths(); @@ -1328,8 +1329,6 @@ int main(int argc, char *argv[]) if (wait_handle == INVALID_HANDLE_VALUE) wait_handle = child; - else - CloseHandle(child); } if (game_process) @@ -1346,5 +1345,12 @@ int main(int argc, char *argv[]) CloseHandle(event); if (event2 != INVALID_HANDLE_VALUE) CloseHandle(event2); - return 0; + + if (child != INVALID_HANDLE_VALUE) + { + GetExitCodeProcess(child, &rc); + CloseHandle(child); + } + + return rc; }