You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Gemini CLI is spawned inside tmux panes, shell commands fail with Signal: 1 (SIGHUP) and produce empty output. Built-in shell commands (echo) work, but external binaries (ls, grep, cargo, npm) are killed immediately.
Workaround identified: Setting enableInteractiveShell: false in settings.json resolves the issue completely.
Environment
OS: Ubuntu Linux 6.17.0-8-generic
Gemini CLI: 0.22.5
tmux: 3.5a
Runtime: bun 1.3.5
Spawn method: gemini --yolo inside tmux pane
Steps to Reproduce
Start a tmux session: tmux new -s test
Inside the tmux pane, launch Gemini CLI: gemini --yolo
Ask Gemini to run a shell command: "Run ls -la"
Observe the output shows Signal: 1 with empty output
Observed Behavior
Commands that WORK:
echo hello world → Output: "hello world", Signal: 0
read_file → works
list_directory → works
Commands that FAIL:
ls -la → Output: (empty), Signal: 1
which ls → Output: (empty), Signal: 1
grep "pattern" file → Output: (empty), Signal: 1
cargo test → Output: (empty), Signal: 1
npm run build → Output: (empty), Signal: 1
Root Cause Analysis
Based on source code analysis and session forensics:
1. PTY Initialization Fails in tmux
When enableInteractiveShell: true (default behavior when the setting is present), Gemini CLI attempts to use node-pty for shell execution. In tmux panes:
PTY initialization can fail (due to /dev/ptmx access or native module issues)
CLI falls back to child_process.spawn with detached: true
2. Detached Process Group Gets Orphaned
On Linux, detached: true creates a new process group. In tmux:
The detached process group becomes "orphaned"
Per POSIX, orphaned process groups receive SIGHUP
3. Signal Handling Difference
Bash: Ignores SIGHUP when running detached (SIG_IGN inherited)
External binaries: Reset signal handler to default (SIG_DFL = terminate)
Result: Bash builtins work, but any forked external binary is immediately killed by the pending SIGHUP
tmux server being killed - possibly related to process group handling
Suggested Improvements
Documentation: Document that tmux users should set enableInteractiveShell: false
Auto-detection: Detect $TMUX environment variable and automatically disable interactive shell:
if(process.env.TMUX){options.detached=false;}
Fallback behavior: When node-pty fails, don't use detached: true in the child_process fallback
Warning message: If shell commands fail with Signal 1, suggest the workaround to the user
Use Case
We're running multi-agent development swarms using ntm which spawns Claude, Codex, and Gemini agents in tmux panes. Gemini agents were entering infinite loops because shell commands kept failing, triggering loop protection, and bricking the agents.
The enableInteractiveShell: false workaround makes Gemini agents fully functional for development tasks in tmux environments.
Questions
Is this the expected behavior when node-pty fails?
Should the fallback code path avoid detached: true?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion: Shell Commands Fail with Signal 1 (SIGHUP) in tmux Panes
Repository: google-gemini/gemini-cli
Category: Bug Report / Workaround Documentation
Related Issues: #12878, #15384, #13396
Summary
When Gemini CLI is spawned inside tmux panes, shell commands fail with
Signal: 1(SIGHUP) and produce empty output. Built-in shell commands (echo) work, but external binaries (ls,grep,cargo,npm) are killed immediately.Workaround identified: Setting
enableInteractiveShell: falseinsettings.jsonresolves the issue completely.Environment
gemini --yoloinside tmux paneSteps to Reproduce
tmux new -s testgemini --yolols -la"Signal: 1with empty outputObserved Behavior
Commands that WORK:
Commands that FAIL:
Root Cause Analysis
Based on source code analysis and session forensics:
1. PTY Initialization Fails in tmux
When
enableInteractiveShell: true(default behavior when the setting is present), Gemini CLI attempts to usenode-ptyfor shell execution. In tmux panes:/dev/ptmxaccess or native module issues)child_process.spawnwithdetached: true2. Detached Process Group Gets Orphaned
On Linux,
detached: truecreates a new process group. In tmux:3. Signal Handling Difference
Evidence from session logs:
{ "command": "echo hello world", "Exit Code": 0, "Signal": 0 // Works - bash builtin } { "command": "ls -la /home/ubuntu", "Exit Code": 0, "Signal": 1 // Killed by SIGHUP - external binary }Workaround (Verified Working)
Add to
~/.gemini/settings.json:{ "tools": { "shell": { "enableInteractiveShell": false } } }Result: ALL shell commands work correctly.
Test results after applying fix:
Trade-off
Interactive commands (
vim,htop,git rebase -i) won't work. For agent automation and development tasks, this is acceptable.Relationship to Existing Issues
Suggested Improvements
Documentation: Document that tmux users should set
enableInteractiveShell: falseAuto-detection: Detect
$TMUXenvironment variable and automatically disable interactive shell:Fallback behavior: When
node-ptyfails, don't usedetached: truein the child_process fallbackWarning message: If shell commands fail with Signal 1, suggest the workaround to the user
Use Case
We're running multi-agent development swarms using ntm which spawns Claude, Codex, and Gemini agents in tmux panes. Gemini agents were entering infinite loops because shell commands kept failing, triggering loop protection, and bricking the agents.
The
enableInteractiveShell: falseworkaround makes Gemini agents fully functional for development tasks in tmux environments.Questions
detached: true?CC: @krasmussen37
Beta Was this translation helpful? Give feedback.
All reactions