Linux/systemd: tmux server crashes with stale socket due to cgroup race condition in tmux-spawn scopes

Resolved 💬 3 comments Opened Apr 1, 2026 by kcgcom Closed May 22, 2026

Summary

On Linux with systemd, Claude Code creates tmux-spawn-*.scope systemd scopes to track tmux child panes spawned by agent mode. When these panes are short-lived, a race condition causes systemd to fail adding the PID to the cgroup — eventually crashing the tmux server and leaving a stale socket.

Environment

  • Claude Code: 2.1.89
  • OS: Linux 6.17.13-1-pve (Proxmox VE)
  • systemd: 255 (255.4-1ubuntu8.14)
  • tmux: 3.4

Steps to Reproduce

  1. Use Claude Code in agent mode on Linux (e.g., with oh-my-claudecode or multi-agent workflows)
  2. Agents spawn and quickly exit tmux panes repeatedly
  3. Over time, observe tmux server crash

Error in journalctl

systemd[...]: tmux-spawn-<uuid>.scope: Couldn't move process <PID> to requested cgroup
              '/user.slice/user-1000.slice/user@1000.service/tmux-spawn-<uuid>.scope': No such process
systemd[...]: tmux-spawn-<uuid>.scope: Failed to add PIDs to scope's control group: No such process
systemd[...]: tmux-spawn-<uuid>.scope: Failed with result 'resources'.
systemd[...]: Failed to start tmux-spawn-<uuid>.scope - tmux child pane <PID> launched by process <PPID>.

Symptom

After the failure, the tmux server is dead but the socket remains:

$ tmux ls
no server running on /tmp/tmux-1000/default

$ ls -la /tmp/tmux-1000/
srw-rw----  1 dev dev 0 Apr  1 16:39 default   ← stale socket

Any subsequent tmux command fails with server exited unexpectedly.

Root Cause

Claude Code uses systemd-run (or equivalent) to create a transient scope per tmux child pane. If the pane process exits before systemd finishes cgroup registration, systemd logs No such process and fails with resources. This failure cascade destabilizes the tmux server.

Workaround

rm /tmp/tmux-$(id -u)/default
tmux

Suggested Fix

  • Use --no-block or handle the resources failure gracefully so a single short-lived pane failure does not crash the tmux server
  • Or skip systemd scope creation for very short-lived panes

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗