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

  1. 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'
``

  1. While the command is running (shows "Running..." in UI), press Escape
  2. Run /tasks command

Expected Behavior

  • Pressing Escape should cancel the running foreground command
  • Or the command should appear in /tasks so it can be killed

Actual Behavior

  • Escape does not cancel the command
  • /tasks shows "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:

  1. SSH creates a nested shell on the remote server
  2. The for-loop runs inside that remote shell
  3. Escape/interrupt signal doesn't propagate through the SSH connection to the nested process
  4. 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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗