Foreground Bash command cannot be cancelled with Escape
Resolved 💬 3 comments Opened Jan 23, 2026 by zzelner Closed Jan 26, 2026
Description
A foreground Bash command running via SSH with an embedded for-loop cannot be cancelled. Pressing Escape does not stop the command, and /tasks shows no running tasks.
Steps to Reproduce
- Run a Bash command in Claude Code that SSHs to a remote server with an embedded loop:
``bash``
ssh remote-server 'for i in 1 2 3; do curl -s -X POST http://localhost:3333/queue -H "Content-Type: application/json" -d "{\"workflowId\": \"xxx\"}"; done'
- While the command is running (shows "Running..." in UI), press
Escape - Run
/taskscommand
Expected Behavior
- Pressing
Escapeshould cancel the running foreground command - Or the command should appear in
/tasksso it can be killed
Actual Behavior
Escapedoes not cancel the command/tasksshows "No tasks currently running"- The command continues running indefinitely
- User is stuck with no way to cancel from within Claude Code
Workaround
Kill the process on the remote server directly:
ssh remote-server 'pkill -f "curl.*localhost:3333"'
Environment
- macOS (Darwin 25.0.0)
- Claude Code CLI
Screenshots
The UI shows the Bash command with "Running..." but /tasks reports no background tasks.
Analysis
The issue may be that:
- SSH creates a nested shell on the remote server
- The for-loop runs inside that remote shell
Escape/interrupt signal doesn't propagate through the SSH connection to the nested process- Since it's not a "background" task, it doesn't appear in
/tasks
This leaves users with no way to cancel the command from within Claude Code.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗