Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 14, 2025

Prevents zombie processes from exec() calls by wrapping them in a disposable resource that guarantees cleanup via TypeScript's using declarations.

Core Solution

All git operations now use explicit resource management:

using proc = execAsync("git status");
const { stdout } = await proc.result;
// Process is automatically cleaned up when scope exits

Key implementation details:

  • Uses close event instead of exit to ensure all stdio streams are fully flushed before resolving
  • Only kills processes that haven't exited naturally (checks exitCode and signalCode)
  • Rejects when process is killed by signal (e.g., SIGTERM)

Additional Fixes

  • Added .unref() to detached terminal spawns on macOS/Windows
  • ESLint rule prevents future promisify(exec) usage
  • Centralized in src/utils/disposableExec.ts to avoid duplication

Testing

  • ✅ All unit tests pass (418 tests)
  • ✅ All integration tests pass (74 tests)
  • ✅ All E2E tests pass
  • ✅ ESLint rule active

Generated with cmux

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

@ammar-agent ammar-agent force-pushed the zombie-process branch 3 times, most recently from 588bc9e to 6913476 Compare October 15, 2025 03:03
@ammario ammario added this pull request to the merge queue Oct 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 15, 2025
Wraps all exec() calls with DisposableExec that uses TypeScript 'using'
declarations to guarantee child process cleanup even on errors. Adds
.unref() to detached terminal spawns on macOS/Windows.

Regression tests + ESLint rule prevent future unsafe patterns.
@ammario ammario enabled auto-merge October 15, 2025 03:14
@ammario ammario added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 8de6d12 Oct 15, 2025
7 checks passed
@ammario ammario deleted the zombie-process branch October 15, 2025 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants