Skip to content

Orphaned gyoshu_bridge.py and node processes not cleaned up on session exit #1724

@blue-int

Description

@blue-int

Bug Description

When a Claude Code session terminates, OMC-spawned child processes are not cleaned up and remain as orphaned processes (PPID 1). Over time, this causes severe memory exhaustion.

Observed Behavior

On a 48GB RAM Mac, memory free dropped to 39% due to accumulated orphaned processes:

Process Count Description
gyoshu_bridge.py 95 MCP bridge Python processes (all PPID 1)
omx hud --watch 6 HUD watcher node processes
codex --dangerously-bypass-approval 5+ Stale codex sessions
oh-my-codex MCP servers ~30 Codex MCP child processes

Total: ~116 node processes (3.5 GB) and ~95 Python processes orphaned.

After manual cleanup: memory free went from 39% → 75%.

Root Cause (suspected)

When the parent Claude Code process exits, child processes spawned by OMC are not receiving SIGTERM. The gyoshu_bridge.py bridge process does not appear to detect parent process termination and self-terminate.

Expected Behavior

When a Claude Code session exits:

  1. gyoshu_bridge.py should detect parent exit and self-terminate
  2. omx hud --watch should be killed
  3. All codex/oh-my-codex child processes should be cleaned up

Possible Fix

  • Set up a parent PID watcher in gyoshu_bridge.py (e.g., poll os.getppid() or use prctl(PR_SET_PDEATHSIG) equivalent on macOS)
  • Use process groups so all children can be killed together via killpg()
  • Register cleanup in Claude Code's exit hook

Environment

  • OMC version: 4.8.2
  • OS: macOS (Darwin 25.3.0, Apple Silicon)
  • RAM: 48 GB
  • Claude Code sessions: 14 concurrent sessions before cleanup

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsRelated to agent definitions

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions