-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
If any plugin or script calls tmux <command>
, then number_tmux_processes_except_current_server
incorrectly reports an overly large value. This causes several problems, including lack of auto-start.
Log:
$ pkill tmux
$ killall tmux
$ tmux
$ tail ~/debug.log
current_tmux_server_pid=2172701
all_tmux_processes:
tmux 2172699 <---- !!! (No idea why this shows up, tbh.)
tmux 2172701
tmux show-option -gqv statu 2172857 <---- !!! (Also problematic.)
number_tmux_processes_except_current_server=2
$ tmux kill-server
$ tail ~/debug.log
current_tmux_server_pid=2173444
all_tmux_processes:
tmux 2173442
tmux 2173444
number_tmux_processes_except_current_server=1
Relevant code is in tmux-continuum/scripts/helpers.sh
:
get_tmux_option() {
local option="$1"
local default_value="$2"
local option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
set_tmux_option() {
local option="$1"
local value="$2"
tmux set-option -gq "$option" "$value"
}
# multiple tmux server detection helpers
current_tmux_server_pid() {
echo "$TMUX" |
cut -f2 -d","
}
all_tmux_processes() {
# ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
local user_id=$(id -u)
ps -u $user_id -o "command pid" |
\grep "^tmux" |
\grep -v "^tmux source"
}
number_tmux_processes_except_current_server() {
all_tmux_processes |
\grep -v " $(current_tmux_server_pid)$" |
wc -l |
sed "s/ //g"
}
number_current_server_client_processes() {
tmux list-clients |
wc -l |
sed "s/ //g"
}
another_tmux_server_running_on_startup() {
# there are 2 tmux processes (current tmux server + 1) on tmux startup
[ "$(number_tmux_processes_except_current_server)" -gt 1 ]
}
Helpful code for debugging:
another_tmux_server_running_on_startup() {
echo "current_tmux_server_pid=$(current_tmux_server_pid)" >> ~/debug.log
echo "all_tmux_processes:" >> ~/debug.log
all_tmux_processes >> ~/debug.log
echo "number_tmux_processes_except_current_server=$(number_tmux_processes_except_current_server)" >> ~/debug.log
# there are 2 tmux processes (current tmux server + 1) on tmux startup
[ "$(number_tmux_processes_except_current_server)" -gt 1 ]
}
Possible fixes:
- Disable multi-tmux detection altogether. Very few users do this anyways.
- Remove interference from
get_tmux_option
viagrep -v '^tmux \(show-option\|set-option\|et cetera\)'
. - Beg the tmux developers for a way to enumerate all tmux servers by user id.
Related:
Farrael
Metadata
Metadata
Assignees
Labels
No labels