Launcher: propagate the native process exit code #15
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Zettrox/ztrx. Originally posted by Yoshi-233 on 2026-11-25T02:56:58Z.
Fixes #3. A batch job invoking
powershell -File scripts/play.ps1currently sees success even when the child reports an error. Save the native exit code immediately after the output pipeline and return it after printing the existing status line. Thanks to @yualk for the Windows reproduction and suggested fix.I exercised the unchanged and patched scripts in separate PowerShell 7.7.0 processes on Ubuntu 24.04.5 x86-64, using a small native child supplied via
-Exe:For each run, the script printed the child status, the log contained both output streams, and the child received the path containing spaces as one argument. I also ran the Linux CLI from #1: its normal “running titles requires Windows” error returned 1 directly, 0 via the original wrapper, and 1 via the patched wrapper. The same diagnostic reached the log.
The Windows PowerShell 5.1 reproduction and its result are in #3. My runs used Linux and required no game files.
Imported from Zettrox/ztrx. Originally posted by kaayzouee on 2026-11-25T03:24:39Z.
Code review — Approved
Reviewed commit
afe450a.Correctness and simplicity
Capturing $LASTEXITCODE immediately after the native process pipeline, printing the captured value, and returning it with exit is correct.
The intervening Out-File cmdlet does not itself overwrite the native process exit code.
The implementation is minimal, readable, and appropriately scoped. Retaining $childExitCode ensures the displayed and returned values remain consistent. No further simplification is necessary.
Nonblocking recommendations
A failure to start the executable is different from a child process returning a nonzero exit code. In the former case, $LASTEXITCODE may be unset or stale.
PR #17 addresses part of this separately. After both changes are merged, consider testing nonexistent executables and executables that exist but cannot be started.
The reported Linux tests covering exit codes 0, 1, 7, and 42 provide useful regression evidence. Retaining these as automated tests and repeating them on Windows PowerShell 5.1 would improve coverage.
Verdict
Approve as-is. No blocking regression identified. The separate executable-discovery and startup-failure concerns should not hold up this change.
Static review only. I inspected the candidate, target branch, related PR #17, and PowerShell documentation. PowerShell was unavailable in my review environment, so the reported tests were not independently executed.
⸻
This is an automated message, if you believe this is incorrect, please reply with the relevant technical context or a reproducible counterexample so the finding can be reassessed.
Imported from Zettrox/ztrx. Originally posted by Yoshi-233 on 2026-11-25T11:59:52Z.
I verified
afe450aon native Windows PowerShell 5.1.26100.9711 usingpowershell.exe -Fileand a small executable passed to-Exe.90b529fafe450aIn all four patched runs, the game path containing spaces and brackets arrived as a single argument, and both stdout and stderr reached
ztrx.log. The combined test with #53 also propagated the child’s exit code after a successful directory retry.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.