Test process termination when the runner holds no console

Nothing in CI exercised process termination when the runner holds no console, which is why the two console defects behind #39684 (closed) survived since 2024. Reproducing that state needs no Windows service and no VM: DETACHED_PROCESS gives a process no console, which is the only precondition the defects need.

  • Add helpers/process/testdata/detached_terminator, a helper that terminates a child process and records the outcome.
  • Start the helper detached, and have it start a second copy of itself detached, so the working copy has no console and no parent console either. AttachConsole(ATTACH_PARENT_PROCESS) then fails exactly as it does under the Service Control Manager.
  • Drive the real entry point, process.NewOSKillWait(...).KillAndWait, rather than the killer directly.
  • Assert the child exits with 3, the code it uses when it is asked to stop. Any other code means it was killed.
  • Cover both the default and the legacy Windows process strategies.

Runs in the existing windows 1809/21H2 integration tests jobs. No new infrastructure.

Closes #39721 (closed)

Scope

The console state is faithful to a service, the session is not: a service runs in session 0, the detached helper does not. Every symptom reported in #39297 (closed) follows from the console state, so this is enough to cover the defects. End-to-end coverage of a runner installed through the Service Control Manager, registered, and running a real job needs its own harness.

Targets 39297-windows-service-console-attach. These assertions only hold once the two fixes below are in, so on main the test would fail:

Merge request reports

Loading
Loading