Agent shell commands survive after Cursor closes, leaving orphaned high-CPU processes in WSL

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When Cursor Agent runs shell commands (e.g. bun test) in WSL, those child processes can outlive the agent session and even survive closing Cursor entirely. They become orphaned under WSL /init, detached from any terminal (TTY ?), and are invisible in the IDE’s terminal panel.

In my case, four bun test processes ran for 19–25+ hours at ~100% CPU each in apiv2/services/fundraising/, with no active Cursor terminal showing them. Process inspection showed PPID /init (2662), confirming the original parent died and the processes were reparented.

The commands matched exact Agent invocations from a prior session (including kill <pid>; bun test test/commit-read.test.ts), suggesting failed cleanup when the agent shell exited or when Cursor was closed.

Cursor is now sluggish on my brand new desktop workstation that has fans running full speed. Not a great UX.

Steps to Reproduce

  1. Use Cursor Agent on WSL (Remote/WSL workspace).
  2. Have the agent run a long-running or hanging shell command, e.g.:
    cd /path/to/project && bun test test/some.test.ts
    (Tests that hang make this easier to observe.)
  3. Let the agent retry or start multiple test runs (agent may run kill <pid>; bun test ... when tests hang).
  4. Close Cursor or end the agent chat while tests are still running.
  5. Reopen Cursor (optional) — only one user terminal may be visible.
  6. In WSL, run ps aux | grep 'bun test' or htop.

Observed: Multiple bun test processes still running, TTY ?, PPID /init, high CPU, not tied to any IDE terminal.

Expected Behavior

When a Cursor Agent shell session ends (timeout, chat closed, or Cursor quit), all child processes started by that shell should be terminated—or at minimum, Cursor should provide a way to see and kill background agent processes.

Closing Cursor should not leave orphaned processes consuming CPU in WSL. Agent-initiated commands should behave like a normal terminal session where closing the session cleans up its process tree.

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

Version: 3.5.17 (user setup)
VSCode Version: 1.105.1
Commit: d5b2fc092e16007956c9e5047f76097b9e626ca0
Date: 2026-05-20T02:43:31.559Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

Cursor Agent (Composer) — exact model not noted at time of session.
Session was an Agent chat that ran shell commands via the Agent tool (not the user terminal).

For AI issues: add Request ID with privacy disabled

Request ID unavailable — original Agent session from ~May 21 is no longer accessible.
Repro is deterministic: Agent runs bun test in WSL → close Cursor → orphaned processes remain under /init.

Additional Information

This is easy to miss (no visible terminal) but can peg multiple CPU cores for days and drain laptop battery. A periodic “background processes” panel or automatic cleanup on agent session end would help.

Does this stop you from using Cursor

Yes - Cursor is unusable

My htop:

cc @deanrie fyi

This is a known bug with how the agent terminal sandbox interacts with WSL. The sandbox process wrapper can hang during initialization, and when the agent retries, old processes aren’t cleaned up. Those orphaned processes get reparented to WSL’s /init and run indefinitely.

Immediate workaround – enable Legacy Terminal Tool:

  1. Open Cursor Settings (gear icon)

  2. Go to Agents

  3. Enable Legacy Terminal Tool

  4. Restart Cursor

This bypasses the sandbox wrapper and should prevent the process accumulation. You lose the sandbox security layer, but your commands will complete and won’t leave orphans.

To clean up the existing orphaned processes, run in your WSL terminal:

pkill -f 'bun test'

Or kill them individually by PID if you prefer more control.

Our team is actively tracking the underlying issue. Your detailed process inspection (PPID /init, TTY ?, 19-25h runtimes) confirms the exact pattern we’re investigating.

Let me know if enabling Legacy Terminal Tool helps.