[BUG] Claude Code exits immediately on HPC interactive sessions - stdin consumed by shell detection subprocesses

Resolved 💬 20 comments Opened Nov 26, 2025 by sankalpsharmaa Closed Mar 16, 2026
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment

| Component | Value |
|-----------|-------|
| Claude Code version | v2.0.54 |
| OS | Rocky Linux 8 (RHEL-based HPC cluster) |
| Shell | bash |
| Node | Not in PATH (Claude Code bundles its own) |
| HPC System | SLURM-managed compute node (USC CARC) |
| Terminal | /dev/pts/1, confirmed TTY |

Description

Claude Code launches, displays the interactive prompt, then immediately exits with code 0. No user input is accepted.

Root Cause (diagnosed via strace)

Claude Code spawns child processes for shell environment detection (aliases, shopts, etc.) that inherit stdin and consume it, causing the main process to receive EOF.

strace evidence:

1752275 read(0, "alias dbcheck='~/check_sync.sh'\n"..., 4096) = 477
1752275 read(0, "", 4096) = 0

Child processes are reading shell configuration data from fd 0 instead of using a separate mechanism. When these processes exhaust stdin, the interactive prompt receives EOF and exits cleanly.

Reproduction

Diagnostic outputs

TTY confirmed:

$ tty
/dev/pts/1

$ test -t 0 && echo "stdin is tty" || echo "stdin not tty"
stdin is tty

$ ls -la /proc/$$/fd/0
lrwx------ 1 ssharma9 ssharma9 64 Nov 26 14:03 /proc/1718597/fd/0 -> /dev/pts/1

stty settings (normal):

speed 38400 baud; rows 45; columns 225; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; ...

No $TMOUT set, no problematic bashrc entries.

Attempted workarounds (all failed)

  • [x] script -q /dev/null -c "claude --dangerously-skip-permissions"
  • [x] claude --dangerously-skip-permissions < /dev/tty
  • [x] bash --norc --noprofile -c "claude ..."
  • [x] SHELL=/bin/sh claude ...
  • [x] trap '' TSTP TTIN TTOU before launch
  • [x] setsid bash -c "claude ... </dev/tty" </dev/tty
  • [x] Disabling conda environment
  • [x] script -q -c "claude ..." /dev/null </dev/tty

Expected behavior

Shell detection subprocesses should not inherit stdin from the parent process. They should either:

  1. Have stdin redirected to /dev/null
  2. Use a separate mechanism (environment inspection, sourcing to temp file, etc.)
  3. Open a new file descriptor for the TTY explicitly

Suggested fix

When spawning subprocesses for shell introspection, use:

spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] })
// or
spawn(cmd, args, { stdio: [fs.openSync('/dev/null', 'r'), 'pipe', 'pipe'] })

instead of inheriting stdin.

Impact

Claude Code is unusable in interactive mode on HPC systems. Only claude -p "prompt" non-interactive mode works.

What Should Happen?

Claude Code should remain in interactive mode waiting for user input. Shell detection subprocesses should not consume the parent process's stdin. The interactive prompt should accept keyboard input normally until the user explicitly exits.

Error Messages/Logs

Steps to Reproduce

  1. SSH into an HPC compute node via SLURM interactive session (salloc + srun --pty bash)
  2. Run claude --dangerously-skip-permissions
  3. Observe: banner displays, prompt appears, immediate exit

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.45

Claude Code Version

2.0.54

Platform

Other

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

20 Comments

hrdkbhatnagar · 7 months ago

I am facing the same issue on my HPC as well

hrdkbhatnagar · 7 months ago

Downgrading to 2.0.25 worked for me

For the native install on Linux I did
curl -fsSL https://claude.ai/install.sh | bash -s 2.0.25

billhess · 7 months ago

Same downgrade to 2.0.25 worked for me also on RHEL 8.10

RenlyH · 7 months ago

Same downgrade to 2.0.25 worked for me

My os is Ubuntu 22.04.5 LTS (Jammy Jellyfish)

ngalatis · 7 months ago

I have found 2.0.36 to also work as well.

UPDATE: I have tested multiple version to find the latest that works, I have found the 2.0.42 to be the latest.
This bug seems to be introduced In 2.0.43.

fisherxue · 7 months ago

I'm running into similar issue on remote server (not HPC cluster) with same observed behaviour, but 2.0.25 does not fix for me.

When I run strace -f -e read,ioctl claude 2>&1 | head -200 I get the errors for

[pid 3027613] ioctl(-1, TIOCGPGRP, 0x7ffe31c459a4) = -1 EBADF (Bad file descriptor)
[pid 3027613] ioctl(2, TIOCGPGRP, 0x7ffe31c45874) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 3027613] ioctl(2, TIOCGPGRP, 0x7ffe31c45854) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 3027613] ioctl(4, TCGETS, 0x7ffe31c45930) = -1 ENOTTY (Inappropriate ioctl for device)

github-actions[bot] · 6 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

tim-watcha · 6 months ago

I'm experiencing the same issue when running Claude Code v2.1.3 over SSH on Ubuntu 18.04.6 LTS (glibc 2.27, zsh shell, TERM=xterm-256color).

The welcome screen and theme selection menu appear normally, but the process exits immediately (exit code 0) without accepting any input. Debug log shows "Creating shell snapshot for zsh" right before exit.

Non-interactive mode works fine (claude --help, claude --version, claude -p "prompt"). This confirms the stdin consumption issue is still present in v2.1.3.

Downgrading to v2.0.42 resolved the issue for me, confirming the bug was introduced between v2.0.42 and v2.0.43. I tested v2.0.43 and it also fails, so the bug was introduced in v2.0.43.

ludolugo · 6 months ago

i'm still experiencing the same issue, installing with curl -fsSL https://claude.ai/install.sh | bash -s 2.0.42 i got the same error, even with curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58 , i'm on almalinux 8

Cheng-WH · 6 months ago

i'm still experiencing the same issue, the Linux version is:
VERSION="8.10 (Green Obsidian)"

ngalatis · 6 months ago

Until this is fixed I’m using the node based installation of Claude Code that does not suffer from this bug.
You can uninstall the native installer and use the nodejs installation method.

Wang-Taiwei · 6 months ago

Downgrading to 2.0.25 resolved the issue for me on CentOS 8.
To avoid being automatically upgraded to 2.1.6, which crashes shortly after startup, I disabled the auto-update mechanism.

Ijmir · 6 months ago

having this issue as well on:
Linux xxx 4.19.0-27-cloud-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 GNU/Linux

wkaleem · 6 months ago

Environment:

  • OS: Red Hat Enterprise Linux 8.10 (Ootpa)
  • Kernel: 4.18.0-553.89.1.el8_10.x86_64
  • SLURM: 24.11.6
  • Terminal: SSH via VS Code Remote-SSH to HPC compute node

Issue:
Claude Code v2.0.43+ exits immediately after displaying the welcome screen. It did not accept any user input.

Solution that worked (based on suggestions from above):
Downgrading to 2.0.42:

curl -fsSL https://claude.ai/install.sh | bash -s 2.0.42

Just confirming the bug was introduced in v2.0.43 as others reported. Thanks!

DiaaEddin · 6 months ago

installing with npm worked even for latest version

wolf5996 · 4 months ago

Can also confirm that claude installation with npm on the BMRC cluster solves this exact issue.

halidaee · 4 months ago

also getting this issue. also remedied with v2.0.42.

Distribution:

  • OS: Rocky Linux 8.10 (Green Obsidian)
  • ID: rocky (RHEL/CentOS/Fedora compatible)
  • Support End: 2029-05-31

Kernel:

  • Version: 4.18.0-553.44.1.el8_10.x86_64
  • Build Date: Mon Mar 10 11:32:40 UTC 2025
tianjiaoding · 4 months ago

I am also getting this issue.

Remote server:

uname -a
Linux ideas-login 4.18.0-553.89.1.el8_10.x86_64 #1 SMP Fri Dec 12 10:42:53 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Further, once claude quits automatically, some strange characters show up in my terminal. My iterm2 also keeps telling me the session rings a bell until i kill the specific session.

╭─── Claude Code v2.1.74 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                       │ Tips for getting started                                                                                                  │
│           Welcome back Rick!          │ Run /init to create a CLAUDE.md file with instructions for Claude                                                         │
│                                       │ Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead. │
│                ▐▛███▜▌                │ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│               ▝▜█████▛▘               │ Recent activity                                                                                                           │
│                 ▘▘ ▝▝                 │ No recent activity                                                                                                        │
│                                       │                                                                                                                           │
│   Opus 4.6 · Claude Max · Rick Ding   │                                                                                                                           │
│             /home/tjding              │                                                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ Try "fix typecheck errors"
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ? for shortcuts                                                                                                                                       ◐ medium · /effort
^[P>|iTerm2 3.6.6^[\%                                                                                                                                                        🐍 base  tjding@ideas-login  ~  claude>|iTerm2 3.6.664;1;2;4;6;17;18;21;22;52c
ant-kurt collaborator · 4 months ago

You should no longer see this premature exit on Claude Code 2.1.76.

github-actions[bot] · 3 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.