Skip to content

startup: run.ps1 exits 1 instead of the debugger's exit code when taskkill reports an error for the -Translate watcher #2272

Done

Description

@alvaroolt

Commit or build

main at 1a713de (tools/startup/run.ps1 line 79, added in 37aefad / #2120)

Reproduction

run.ps1 sets $ErrorActionPreference = "Stop" and stops the -Translate watcher in a finally block:

if ($translator) { & taskkill.exe /T /F /PID $translator.Id 2>&1 | Out-Null }

Windows PowerShell 5.1 turns each stderr line of a native command redirected with 2>&1 into an error record, and Stop turns it into a terminating error. Whenever taskkill writes to stderr, the script therefore aborts. Before it aborts, it has printed neither the head of <LogDir>.out nor run exit $debuggerExit. A standalone script shows the mechanism:

# taskkill_stop.ps1 — run with: powershell -NoProfile -ExecutionPolicy Bypass -File taskkill_stop.ps1
$ErrorActionPreference = "Stop"
$p = Start-Process -FilePath cmd.exe -ArgumentList '/c','exit 0' -PassThru -NoNewWindow
$p.WaitForExit()
try {
    & taskkill.exe /T /F /PID $p.Id 2>&1 | Out-Null
    "reached the next statement"
} catch {
    "terminating error: $($_.FullyQualifiedErrorId)"
}
# prints: terminating error: NativeCommandError

Through run.ps1 itself, with the stub tree of tests/startup_run_ps1_check.py (no title files, no debugger): replace WATCH_STUB with a watcher that writes watch.json and exits at once, then call run_case(shell, script, code, tmp, translate=True) for debugger exit codes 0 and 7.

Expected behavior

run.ps1 -Render -Translate prints the first five lines of <LogDir>.out and exits with the debugger's exit code, as it does without -Translate (#1603). This should hold whether the watcher is still running or has already exited (crash, bad cache path or early return) when the debugger finishes. It should also hold when part of its process tree is already gone while taskkill /T walks it.

Observed behavior

With a watcher that has already exited, both cases fail the same way (run with the check from #2271, which reads the localized warning prefix):

stub debugger exited 0, run.ps1 exited 1
stub exit 0: printed ['ADVERTENCIA: Without -FakeUser, ...'], expected ['ADVERTENCIA: Without -FakeUser, ...', 'stub debugger line 1', ..., 'stub debugger line 5']
  (stderr: 'taskkill.exe : ERROR: ... NativeCommandError')
stub debugger exited 7, run.ps1 exited 1

The debugger's exit code is lost and the log head is not printed.

The same error also appeared once, intermittently, with the normal long-running watcher stub. That happened in the -Translate case of tests/startup_run_ps1_check.py during a full tools/run_checks_parallel.py run: run.ps1 exited 1, with stderr taskkill.exe : ERROR: el proceso con PID … (proceso secundario de PID …) (Spanish Windows) pointing at line 79. The check then passed in 8 of 8 serial runs and in 8 of 8 runs started at once, so this path is rare. A watcher that has already exited reproduces the failure every time.

A possible direction, for whoever picks this up: stop the tree without letting taskkill's stderr become a terminating error. For example, check $translator.HasExited first and run taskkill with a local $ErrorActionPreference = "Continue", or through Start-Process -Wait. Add a case to tests/startup_run_ps1_check.py with a watcher that exits early, which must still yield the debugger's exit code and the log head. The existing cleanup controls from #2222 still apply.

Environment

Windows 11 build 26300.9974 (UI language es-ES), Windows PowerShell 5.1.26100.9818, Python 3.12. pwsh 7 was not tested; its handling of native stderr under Stop differs from 5.1. No GPU involved.

Checklist

  • I reproduced this on a source-built input.
  • I did not include game files, dumps, distribution links or credentials.

This report was AI-assisted (Claude Code); I reviewed the reproduction and its output.

Activity

  1. RavenCurseBurg commented on Nov 25, 2026

    @RavenCurseBurg
    Contributor

    I’ll take this using the existing synthetic launcher fixture on Windows PowerShell 5.1 and PowerShell 7. I’ll check the five-line output and debugger exit codes 0 and 7 after the watcher has actually exited, and retain the live parent/child cleanup controls from #2222. I’ll also check the stderr race independently of the early-exit case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions