Skip to content

Commit a7ea4ae

Browse files
committed
Fix tmux_ram_info bug
Occurs with lines too long that get truncated, causing unclosed parentheses and breaking the sed regex. The -l option fixes this. -T is for removing unnecessary PIDs (thread PIDs) from pstree output.
1 parent 6a0d43b commit a7ea4ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/tmux_ram_info.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ get_tmux_ram_usage()
6767
case $(uname -s) in
6868
Linux)
6969
if command -v pstree > /dev/null; then
70-
pids="$(pstree -p "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')"
70+
pids="$(pstree -Tlp "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')"
7171
else
7272
pids="$(get_cpids_linux "$pid" | tr '\n' ',')"
7373
fi
@@ -76,7 +76,7 @@ get_tmux_ram_usage()
7676

7777
Darwin)
7878
if command -v pstree > /dev/null; then
79-
pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
79+
pids="$(pstree -w "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
8080
else
8181
pids="$(get_cpids_unix "$pid" | tr '\n' ',')"
8282
fi
@@ -86,7 +86,7 @@ get_tmux_ram_usage()
8686
FreeBSD)
8787
# TODO check FreeBSD compatibility
8888
if command -v pstree > /dev/null; then
89-
pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
89+
pids="$(pstree -lp "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
9090
else
9191
pids="$(get_cpids_unix "$pid" | tr '\n' ',')"
9292
fi

0 commit comments

Comments
 (0)