[sentinel #11237] fix(lsp): wrap post-Popen init in cleanup guard to prevent orphaned processes #1

Open
HAL9000 wants to merge 2 commits from tests/sentinel-11237-bugfix-m3.6.0-lsp-7044-subprocess-cleanup into master

2 Commits

Author SHA1 Message Date
cleveragents-auto 89eb78d5c4 Merge commit '3d391ddb3a1dfd28beb4271ee9d3ce26a4666bf6' into HEAD 2026-05-21 06:32:45 -04:00
HAL9000 592cd360e7 fix(lsp): wrap post-Popen init in cleanup guard to prevent orphaned processes
Closes #7044

The StdioTransport.start() method had an unprotected logger.info() call
after successful Popen(). If that call raised, the subprocess would
leak as an orphaned process. Wrap all post-spawn initialization in a
try/except guard: on any exception after spawn, terminate and wait for
the process (with kill fallback), reset state to None, then re-raise
so callers still get proper error semantics.

The existing stop() method cleanup pattern (terminate → wait → kill) is
mirrored here for consistency across the transport lifecycle.

Tests added:
  - TDD scenario with @tdd_issue_7044 verifying subprocess cleanup on
    post-Popen exception and state reset to None
  - Explicit is_alive() scenarios covering both alive and not-alive states

Refactoring:
  - Extracted _make_mock_process and _build_lsp_frame helpers into a
    shared _ltcov_helpers module to keep step files under the 500-line
    CONTRIBUTING.md limit.

ISSUES CLOSED: #7044
2026-05-16 16:21:12 +00:00