Skip to content

Add allow-stopped-panes option to permit stopped pane processes - #5650

Open
baleti wants to merge 1 commit into
tmux:masterfrom
baleti:add-stopped-panes-option
Open

baleti wants to merge 1 commit into
tmux:masterfrom
baleti:add-stopped-panes-option

Conversation

@baleti

@baleti baleti commented Sep 27, 2026

Copy link
Copy Markdown

Summary

tmux's SIGCHLD handler (server_child_stopped() in server.c) unconditionally sends SIGCONT to any pane process it finds stopped (WIFSTOPPED), except when the stop signal was SIGTTIN or SIGTTOU. This is hardcoded with no option to disable it.

In practice this means a pane's process can never be suspended from outside tmux - e.g. with an external kill -STOP, a cgroup freezer, or a debugger attaching - because tmux resumes it again almost immediately (observed within tens of milliseconds), regardless of intent.

What this adds

A new window/pane option, allow-stopped-panes, defaulting to off so existing behaviour is unchanged by default. When turned on for a pane, tmux skips the automatic SIGCONT for that pane's process, letting it remain stopped until something else resumes it.

Motivation

Wanted to suspend an idle long-running interactive process (specifically an AI coding assistant CLI) sitting in a tmux pane, to stop it consuming CPU/memory without killing its session. Plain kill -STOP/SIGTSTP cannot do this inside tmux today for the reason above, forcing a much heavier workaround (a cgroup freezer) just to sidestep tmux's own reflex.

Testing

Built from a clean clone (autogen.sh && ./configure && make), ran against an isolated test server (tmux -L patchtest):

  • With allow-stopped-panes off (default): kill -STOP on a pane's process is immediately reversed by tmux, process observed back in state S within 1s - matches current behaviour exactly.
  • With allow-stopped-panes on: kill -STOP on a pane's process leaves it in state T (stopped), confirmed to persist; kill -CONT resumes it normally afterward.

Happy to adjust naming/scope/docs wording if you'd prefer a different approach (e.g. a server-wide option instead of window/pane-scoped).

tmux's SIGCHLD handler unconditionally sends SIGCONT to any pane
process it finds stopped (WIFSTOPPED), other than for SIGTTIN or
SIGTTOU. This makes it impossible to suspend a pane's process from
outside tmux, for example with an external kill -STOP, a cgroup
freezer, or a debugger - tmux immediately resumes it again, often
within milliseconds.

Add a new window/pane option, allow-stopped-panes, defaulting to off
to preserve the existing behaviour. When turned on for a pane, tmux
no longer sends SIGCONT to that pane's process when it is found
stopped, allowing it to be suspended externally (e.g. to stop it
consuming CPU, or before forcing its memory out to swap) and resumed
later without tmux interfering.
@nicm

nicm commented Sep 27, 2026

Copy link
Copy Markdown
Member

I think instead of a yes/no I would rather this was an option with options none/continue, not sure what is a good name - action-on-stop?

I'm thinking that the nicest behaviour would be like remain-on-exit - show a message and allow the user to press a key to continue. I don't necessarily suggest you do that, but if we set the option up to allow more than yes/no now, it would be easier to add this, or some other behaviour, later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting

Development

Successfully merging this pull request may close these issues.

2 participants