Return the real application return code on exit

CW-Bug-Id: #15930
This commit is contained in:
Andrew Eikum 2021-10-27 09:25:56 -05:00
parent 00b867845d
commit 1bac3ae22d
2 changed files with 19 additions and 10 deletions

15
proton
View file

@ -1247,7 +1247,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"]):
@ -1262,7 +1262,7 @@ class Session:
else:
remote_debug_proc = None
self.run_proc([g_proton.wine64_bin, "steam"] + sys.argv[2:] + self.cmdlineappend)
rc = self.run_proc([g_proton.wine64_bin, "steam"] + sys.argv[2:] + self.cmdlineappend)
if remote_debug_proc:
remote_debug_proc.kill()
@ -1273,6 +1273,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?")
@ -1295,16 +1297,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)
@ -1317,7 +1320,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:

View file

@ -1206,7 +1206,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");
@ -1249,7 +1251,6 @@ int main(int argc, char *argv[])
if (argc > 1)
{
HANDLE child;
BOOL should_await;
setup_vrpaths();
@ -1266,8 +1267,6 @@ int main(int argc, char *argv[])
if (wait_handle == INVALID_HANDLE_VALUE)
wait_handle = child;
else
CloseHandle(child);
}
}
@ -1281,5 +1280,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;
}