Files
moeka-project/services/computer-use-mcp/src
Alan-Yu-2077 445b597041 fix(computer-use-mcp): don't orphan background processes on terminal timeout (#2006)
## Description

Noticed this reading the terminal runner: when a `terminal_exec` command
times out we only `SIGTERM` the shell. The shell isn't spawned
`detached`, so anything it backgrounded (`server &`, `nohup`, a dev
server) gets reparented to init and keeps running — an orphan leak on
every timed-out command that backgrounded something.

Fix: spawn the shell `detached` and signal the whole process group
(negative PID) on timeout, SIGTERM → 5s → SIGKILL — same pattern as
`apps/stage-tamagotchi/scripts/desktop-overlay-live-window-smoke.ts`.
Falls back to a single-process kill, non-timeout path unchanged.

## Linked Issues

None — just something I noticed.

## Additional Context

Added a regression test (backgrounds a `sleep`, times out, asserts the
pid is gone) — fails on `main`, passes here. `moeru-lint` clean. Left
PTY teardown (`pty-runner.ts`) out on purpose: job control puts
background jobs in their own groups, needs session-wide cleanup — happy
to follow up.
2026-06-23 12:35:12 +08:00
..
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00
2026-06-07 20:31:22 +08:00