WSL2: Agent terminal spawns nested bash -O extglob / cursorsandbox processes; commands never exit and exhaust the machine

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When the Cursor agent runs a shell command, the command does not complete. Under WSL2, ps shows many nested processes, all running the same wrapped command line. The process tree grows until the environment is saturated and WSL crashes due to out of memory.

Reproduction is not limited to one tool (e.g. a linter). The same behavior occurs with simple shell pipelines (e.g. find + wc), which indicates a problem in agent/sandbox shell execution, not project-specific tooling.

I cannot allow cursor agents to run ANY commands

Example process tree (anonymized):

user@host:~$ ps -ef | grep extglob
user        1001     900  0 13:03 ?        00:00:00 /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"
user        1101    1001  0 13:03 ?        00:00:00 /home/user/.cursor-server/bin/<CURSOR_SERVER_BUILD>/resources/helpers/cursorsandbox --policy /tmp/sandbox-policy-<ID> -- /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"
user        1201    1001  0 13:03 ?        00:00:00 /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"
user        1202    1201  0 13:03 ?        00:00:00 /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"
user        1203    1202  0 13:03 ?        00:00:00 /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"
user        1204    1203  0 13:03 ?        00:00:00 /bin/bash -O extglob -c snap=$(command cat <&3) && builtin shopt -s extglob && builtin eval -- "$snap" && { builtin set +u 2>/dev/null || true; builtin eval "${__CURSOR_SANDBOX_ENV_RESTORE:-}" 2>/dev/null; builtin export PWD="$(builtin pwd)"; builtin shopt -s expand_aliases 2>/dev/null; builtin eval "$1"; }; COMMAND_EXIT_CODE=$?; dump_bash_state >&4; builtin exit $COMMAND_EXIT_CODE -- cd <REPO_ROOT> && timeout 30 yarn run eslint <PATH_TO_FILE> 2>&1; echo "exit=$?"

This repeats until the available memory is used up.

Steps to Reproduce

Open a local project workspace in Cursor on WSL2 (any medium-sized tree is enough).
Ask the agent to run either of the commands below (or run them through the agent shell integration).
Observe: the command does not return; process count / load grows.
In a normal WSL terminal, run: ps -ef | grep extglob (or pstree -p on the top-level PID).

Reproduction commands (masked / generic)
A — Node toolchain (example):

cd <REPO_ROOT> && yarn run <SOME_NPM_SCRIPT_OR_BINARY> <PATH_TO_SINGLE_FILE> 2>&1
B — Not toolchain-specific (filesystem only):

cd <REPO_ROOT> && timeout 60 find <SOME_SUBDIR> -type f ( -name ‘.ts’ -o -name '.tsx’ -o -name '*.

Replace <REPO_ROOT> with any project path, <SOME_SUBDIR> with a real subdirectory under that repo, and <PATH_TO_SINGLE_FILE> / <SOME_NPM_SCRIPT_OR_BINARY> with any valid file and script that would normally finish quickly in a normal terminal.

Expected Behavior

The command should finish instantly or in a few seconds

Operating System

Windows 10/11

Version Information

Linux OPHD-3206 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 24.04.4 LTS

Version: 3.1.14 (user setup)
VSCode Version: 1.105.1
Commit: d8673fb56ba50fda33ad78382000b519bb8acb70
Date: 2026-04-14T01:39:23.679Z
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

Additional Information

I have tried rebuilding my WSL+Ubuntu install from scratch, as well as reinstalling Cursor. I have deleted every cursor-related file I could find.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hi @wmakley,

This is a known issue with how the agent terminal sandbox interacts with WSL2. The sandbox process wrapper can hang during its initialization, and when the agent retries, the old processes aren’t cleaned up, which is why you see the process tree growing until memory is exhausted.

Immediate workaround – try enabling Legacy Terminal Tool:

  1. Open Cursor Settings (via the gear icon)

  2. Go to Agents

  3. Enable Legacy Terminal Tool

  4. Restart Cursor

This bypasses the sandbox wrapper entirely and should prevent the process accumulation. It means you lose the sandbox security layer, but your commands will actually complete.

If that doesn’t resolve it, you can also try switching the agent approval mode away from “Allowlist” (which is what enables the sandbox). Set it to “Ask” mode temporarily to test.

You may also find this related thread helpful: Run_terminal_cmd hangs forever after calling WSL shell

Our team is aware of the underlying terminal hang issue and it’s being tracked. Your report with the detailed process tree is very helpful – the OOM angle from process accumulation is a new data point.

Let me know if enabling Legacy Terminal Tool helps!