Summary
save_command_strategies/pgrep.sh uses pgrep -lf -P "$PANE_PID", which prints each child's argument list verbatim. If a pane is running a command whose arguments contain a newline (for example a multi-line snippet typed at the prompt, or bash -c $'a\nb'), the strategy emits multiple lines for that one pane.
save.sh writes one tab-delimited record per pane, so the extra lines land in the save file as garbage records. Restore then either skips the pane or misparses subsequent fields.
Reproduce
In any shell (a tmux pane is not required, only a parent PID):
bash -c 'echo $$ > /tmp/parent.pid; bash -c "sleep 60
sleep 60" & wait' &
sleep 1
save_command_strategies/pgrep.sh "$(cat /tmp/parent.pid)" | cat -A
Output with the current strategy (three lines for one child process):
bash -c sleep 60$
sleep 60$
The default ps strategy renders the same process on a single line, with the newline escaped:
bash -c sleep 60\012sleep 60$
Why it matters
The ps strategy runs ps -ao ppid,args (a full process-table dump) once per pane, which gets slow with many panes and is the likely cause of reports like #544. The pgrep strategy is the natural cheaper alternative, since pgrep -P asks the kernel for one pane's children directly, but it is not safe to use because of the above.
Fix
Ask pgrep -P only for the child PIDs, then format them with ps -o args= -p <pids>. That produces the same output as the ps strategy while keeping the per-pane cost low. PR to follow.
Summary
save_command_strategies/pgrep.shusespgrep -lf -P "$PANE_PID", which prints each child's argument list verbatim. If a pane is running a command whose arguments contain a newline (for example a multi-line snippet typed at the prompt, orbash -c $'a\nb'), the strategy emits multiple lines for that one pane.save.shwrites one tab-delimited record per pane, so the extra lines land in the save file as garbage records. Restore then either skips the pane or misparses subsequent fields.Reproduce
In any shell (a tmux pane is not required, only a parent PID):
Output with the current strategy (three lines for one child process):
The default
psstrategy renders the same process on a single line, with the newline escaped:Why it matters
The
psstrategy runsps -ao ppid,args(a full process-table dump) once per pane, which gets slow with many panes and is the likely cause of reports like #544. Thepgrepstrategy is the natural cheaper alternative, sincepgrep -Pasks the kernel for one pane's children directly, but it is not safe to use because of the above.Fix
Ask
pgrep -Ponly for the child PIDs, then format them withps -o args= -p <pids>. That produces the same output as thepsstrategy while keeping the per-pane cost low. PR to follow.