proton: 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 committed by Arkadiusz Hiler
parent ef7b6fd07e
commit fdc3651992
2 changed files with 19 additions and 10 deletions

15
proton
View file

@ -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:

View file

@ -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;
}