Conversation
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.
Member
|
I think instead of a yes/no I would rather this was an option with options I'm thinking that the nicest behaviour would be like |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tmux's SIGCHLD handler (
server_child_stopped()inserver.c) unconditionally sendsSIGCONTto any pane process it finds stopped (WIFSTOPPED), except when the stop signal wasSIGTTINorSIGTTOU. 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 tooffso existing behaviour is unchanged by default. When turned on for a pane, tmux skips the automaticSIGCONTfor 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/SIGTSTPcannot 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):allow-stopped-panes off(default):kill -STOPon a pane's process is immediately reversed by tmux, process observed back in stateSwithin 1s - matches current behaviour exactly.allow-stopped-panes on:kill -STOPon a pane's process leaves it in stateT(stopped), confirmed to persist;kill -CONTresumes 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).