Files
vscode/cli
Connor Peet f8a55977f7 Kill full server process tree in agent host kill_running_server (#320631)
* Kill full server process tree in agent host kill_running_server

The CLI agent host supervisor launches the server via a shell shim
(`<server>/bin/code-server-<quality>`) that spawns `node ... server-main.js`,
which in turn spawns a `bootstrap-fork` agent host process. The previous
`child.kill()` in `kill_running_server` only terminated the shim, leaving
the node descendants reparented to PID 1.

Route the shutdown through `kill_tree` instead, and have the non-Windows
`kill_tree` walk the full descendant tree via `pgrep -P` rather than just
the direct children. Add a depth-3 process-tree unit test on Unix.

Fixes #319516

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix flaky kill_tree test by reaping spawned child process

The previous test relied on `process_exists` to confirm pids were gone,
but on Linux the outer sh remains a zombie until its parent (the test
runtime) reaps it. Await `child.wait()` immediately after `kill_tree`
so the outer sh is reaped, and rely on init to reap the orphaned
descendants. Also bumps the deadline to 10s to absorb init latency.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Bound kill_running_server wait and check pgrep exit status

Addresses Copilot review feedback:
- kill_running_server: bound child reap with a 5s timeout; escalate to
  SIGKILL via Child::kill if a process ignores SIGTERM, so a misbehaving
  server can't wedge the supervisor's shutdown or upgrade path.
- children_of: distinguish pgrep exit codes — 0/1 are expected (matches
  vs no matches), 2/3 are surfaced as CommandFailed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-09 18:28:53 +00:00
..