Skip to content

Conversation

@deflating
Copy link

Summary

  • Fixes orphan Claude Code processes when installed as native binary
  • Adds SIGTERM/SIGINT signal forwarding in launcher and SDK

Problem

When Claude Code is installed as a native binary (via native installer, not npm), the launcher spawns it as a child process. If the parent process receives SIGTERM/SIGINT (e.g., when switching modes or aborting), it would exit without forwarding the signal to the child. This leaves Claude binary processes running as orphans (PPID becomes 1), consuming memory indefinitely.

Solution

Added signal handlers in two places:

  1. scripts/claude_version_utils.cjs - forwards SIGTERM/SIGINT to spawned binary child
  2. src/claude/sdk/query.ts - adds signal handlers alongside existing cleanup logic

Test plan

  • Start Happy with native binary Claude installation
  • Send message, switch to remote mode (triggers abort)
  • Verify Claude process terminates (check ps aux | grep claude)
  • Previously: orphaned process with PPID=1; Now: process should be gone

🤖 Generated with Claude Code

When Claude Code is installed as a native binary (not npm), the launcher
spawns it as a child process. If the launcher receives SIGTERM/SIGINT,
it would exit without forwarding the signal, leaving the Claude binary
running as an orphan (PPID becomes 1).

This adds signal forwarding in two places:
- claude_version_utils.cjs: forwards signals when spawning binary Claude
- sdk/query.ts: adds SIGTERM/SIGINT handlers to cleanup spawned processes

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
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.

1 participant