Skip to content

Severe PTY leak in qwen CLI causes tmux split/new-window failures (out of pty devices) #2313

@Essviv

Description

@Essviv

Bug Description

After running qwen -y for long sessions, the process leaks PTY file descriptors (/dev/ptmx) and eventually exhausts system PTY capacity.
When this happens, tmux can no longer create panes/windows.

Environment

  • OS: macOS 15.5 (Darwin 24.5.0)
  • Shell: zsh
  • tmux: 3.6a
  • qwen CLI launched as: qwen -y
  • Node runtime observed in process tree

Expected Behavior

qwen -y should not continuously accumulate PTY descriptors.
tmux should continue to split panes/create windows normally.

Actual Behavior

After long-running qwen sessions:

  • tmux split-window / tmux new-window fails with:
    • create window failed: fork failed: Device not configured
  • Python PTY test fails with:
    • OSError('out of pty devices')

Diagnostics

  • Kernel PTY max observed: kern.tty.ptmx_max: 511
  • One qwen -y node process held ~444 /dev/ptmx descriptors
  • Another qwen -y process held ~50 /dev/ptmx descriptors
  • Top PTY holders showed qwen dominating PTY usage
  • After killing those qwen processes:
    • PTY allocation worked immediately (openpty ok)
    • tmux pane split worked again

Minimal Reproduction (long-run)

  1. Start qwen -y and keep it running with multiple tool/task operations for many hours.
  2. Periodically check PTY usage:
    lsof -nP /dev/ptmx | awk 'NR>1{c[$2]++; cmd[$2]=$1} END{for (p in c) printf "%5d %s %s\\n", c[p], p, cmd[p]}' | sort -nr | head
  3. Observe qwen process PTY count continuously increasing.
  4. Eventually tmux split-window fails with the error above.

Notes

This appears to be a PTY/FD cleanup leak in long-lived qwen sessions.
Please investigate PTY lifecycle management and child process teardown paths.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions