[BUG] Claude Code exits immediately on HPC interactive sessions - stdin consumed by shell detection subprocesses
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 TTOUbefore 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:
- Have stdin redirected to
/dev/null - Use a separate mechanism (environment inspection, sourcing to temp file, etc.)
- 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
- SSH into an HPC compute node via SLURM interactive session (
salloc+srun --pty bash) - Run
claude --dangerously-skip-permissions - 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_
20 Comments
I am facing the same issue on my HPC as well
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.25Same downgrade to 2.0.25 worked for me also on RHEL 8.10
Same downgrade to 2.0.25 worked for me
My os is
Ubuntu 22.04.5 LTS (Jammy Jellyfish)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.
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 -200I 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)
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.
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.
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
i'm still experiencing the same issue, the Linux version is:
VERSION="8.10 (Green Obsidian)"
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.
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.
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/LinuxEnvironment:
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:
Just confirming the bug was introduced in v2.0.43 as others reported. Thanks!
installing with npm worked even for latest version
Can also confirm that claude installation with npm on the BMRC cluster solves this exact issue.
also getting this issue. also remedied with v2.0.42.
Distribution:
Kernel:
I am also getting this issue.
Remote server:
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.
You should no longer see this premature exit on Claude Code 2.1.76.
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.