[BUG] Ctrl-G external editor invocation causes TTIN suspension and EINTR crash with emacs
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:
- Claude Code Version: 2.0.37
- OS: macOS (Darwin 25.0.0)
- Shell: zsh with oh-my-zsh
- EDITOR: emacs -nw (GNU Emacs 30.2)
- Installation method: Native installer (shell script, not npm)
# Description:
When attempting to use Ctrl-G to edit a long prompt in an external editor (as suggested by the CLI when lines exceed the terminal width), Claude Code suspends with a TTIN signal instead of launching the editor.
# Actual Behavior:
- Claude Code process suspends immediately with:
zsh: suspended (tty input) claude --resume
- The terminal shows TTIN status (terminal input while backgrounded)
- Running
fgto bring the process to the foreground results in a crash with the following error: - The stack trace shows an attempt to access a non-existent lock file:
Error: ENOENT: no such file or directory, stat '/Users/capehart/.local/state/claude/locks/2.0.35.lock'
- (Note: The lock file references version 2.0.35, but I'm running 2.0.37)
Possible Root Cause (as identified by Claude):
The editor appears to be launched as a background process without proper TTY control, causing the OS to suspend it when it attempts to read from stdin. The subsequent lock file error suggests a state management issue when recovering from the suspension.
What Should Happen?
Emacs should launch in terminal mode (-nw) to edit the prompt, then return the edited text to Claude Code when exiting the editor.
Error Messages/Logs
EINTR: interrupted system call, read
fd: 8,
syscall: "read",
errno: -4,
code: "EINTR"
Steps to Reproduce
- Start Claude Code CLI session
- Begin typing a prompt that exceeds one line
- Press Ctrl-G (as instructed by the "Press ^G to edit with emacs" message)
- Observe the process suspension
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.37 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
Additional Context:
- The ~/.local/state/claude/locks/ directory exists
- Multiple previous Ctrl-G attempts can be brought to foreground with successive fg commands, each resulting in the same crash
- After all suspended processes are exhausted with fg, Claude Code does not return to normal operation
- This appears to be a TTY handling issue where the editor subprocess is being spawned without proper terminal control
❯ echo ${EDITOR}
emacs -nw
❯ emacs --version
GNU Emacs 30.2
❯ which emacs
/opt/homebrew/bin/emacs
<img width="1290" height="813" alt="Image" src="https://github.com/user-attachments/assets/ce1efc5b-9bb8-44da-b33c-451b44a8e8a2" />
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗