Skip to content

ps.sh maxes out CPU on macOS after waking from sleep #544

@bagonyi

Description

@bagonyi

On macOS, after the computer wakes from sleep, multiple ps.sh processes can run and max out the CPU. This happens once every few weeks after I open the lid of my Macbook. The remedy is to kill the tmux server, and restart the terminal. But this usually results in either the tmux sessions and/or the window names being lost.

[Logs] 0:zsh 1:zsh 2:zsh 3:zsh 4:zsh- 5:zsh*

In the Logs session I had 6 windows open, each with a custom name, but now, after restarting the tmux server, I am left with nameless windows.

To restore the window names, I have to look for the most recent non-corrupted tmux_resurrect_*.txt in ~/.tmux/resurrect and update the last symlink to it:

tmux kill-server
cd ~/.tmux/resurrect
ln -sf tmux_resurrect_20250701T210804.txt last
tmux

My ~/.tmux/plugins/tmux-resurrect is on cff343cf9e81983d3da0c8562b01616f12e8d548.


Gemini's opinion (although I couldn't find any supporting evidence online):

This is likely due to the ps command hanging, which is a known issue on macOS.

A potential fix is to add the -c flag to the ps command in save_command_strategies/ps.sh like so:

--- a/save_command_strategies/ps.sh
+++ b/save_command_strategies/ps.sh
@@ -13,7 +13,7 @@
 
 full_command() {
-	ps -ao "ppid,args" |
+	ps -cao "ppid,args" |
 		sed "s/^ *//" |
 		grep "^${PANE_PID}" |
 		cut -d' ' -f2-
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions