Skip to content

fix: prevent Computer Use subprocess leak on macOS#1182

Open
guangsizhongbin wants to merge 1 commit into
BigPizzaV3:mainfrom
guangsizhongbin:fix/macos-computer-use-cleanup
Open

fix: prevent Computer Use subprocess leak on macOS#1182
guangsizhongbin wants to merge 1 commit into
BigPizzaV3:mainfrom
guangsizhongbin:fix/macos-computer-use-cleanup

Conversation

@guangsizhongbin

Copy link
Copy Markdown

Problem

Codex spawns a SkyComputerUseClient subprocess for each Computer Use session via the openai-bundled computer-use plugin, but does not reliably clean them up when conversations end. Over time these orphaned processes accumulate (~20MB RSS each), causing swap pressure and UI freezes.

On macOS, Codex++'s computer_use_guard was a no-op — all guard functionality was #[cfg(windows)] only.

Changes

computer_use_guard.rs

Added kill_orphaned_computer_use_processes() for macOS that uses pkill -f SkyComputerUseClient to clean up orphaned processes. Codex re-spawns them lazily on the next Computer Use session, so killing them is safe.

node_repl processes are intentionally left alone — they are lightweight (~1MB RSS) and killing them could disrupt in-flight code execution.

launcher.rs

Added a macOS-specific computer_use_guard_watchdog that runs every 120 seconds in a background tokio task. The watchdog is always active on macOS (not gated on computer_use_guard_enabled, which is a Windows-specific setting).

relay_config.rs

Replaced && let_chains syntax with nested if let blocks for broader Rust version compatibility. The let_chains feature requires nightly or specific Rust ≥1.86 nightly features.

Testing

  • Compiles on Rust 1.87.0 (arm64 macOS)
  • Binary runs as menu bar app
  • Watchdog is registered via start_computer_use_guard_watchdog and runs every 2 minutes
  • Cleanup successfully kills orphaned SkyComputerUseClient processes

Codex spawns a SkyComputerUseClient subprocess for each Computer Use
session via the openai-bundled computer-use plugin, but does not
reliably clean them up when conversations end. On macOS, these orphaned
processes accumulate (~20MB RSS each), eventually causing swap pressure
and UI freezes.

Changes:

- computer_use_guard.rs: Add kill_orphaned_computer_use_processes()
  for macOS that uses pkill to clean up SkyComputerUseClient processes.
  Codex re-spawns them lazily on the next Computer Use session, so this
  is safe to run periodically.

- launcher.rs: Add a macOS-specific computer_use_guard_watchdog that
  runs every 120 seconds and kills orphaned Computer Use subprocesses.
  The watchdog is always active on macOS (not gated on the
  computer_use_guard_enabled setting, which is Windows-specific).

- relay_config.rs: Replace && let_chains syntax with nested if let
  blocks for broader Rust version compatibility.
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