Running `ps -t /dev/<tty>` started causing the specified terminal to stop receiving most keystrokes
3
votes
1
answer
287
views
### Specific Problem
Running
ps -t /dev/
recently started causing the associated terminal to stop receiving some keystrokes. I can't fathom why this started happening now, without any software updates that I'm aware of.
After running the ps
command, most keystrokes will no longer make it through to this shell or whatever program is running in the tty (e.g. if you run it from in a vim subshell). Only a subset make it through, requiring repeating keypresses several times before they register, as if eaten by another process. Repeated runs of ps -t
exacerbate the problem further.
### To Reproduce
Notably, I can only reproduce this on one of my machines.
ps -t $(tty)
A significant percentage of keystrokes are dropped from the TTY now.
It can be run on the current TTY or another TTY. The target TTY is affected.
To recover from this, exit the TTY using Ctrl+D or exit
. (Keystrokes will need to be entered repeatedly.)
I'd be interested to hear who can and cannot reproduce this.
### Why This is Needed
[vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator) uses this tmux configuration to detect whether vim is the active process in the current tmux pane, in order to allow seamless navigation within and between vim splits and tmux panes.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | \
grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L"
bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D"
bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U"
bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R"
### Versions
I can reproduce this on both MacOS 14.6.1 and 15.2.
The /bin/ps
executable hasn't been touched in a few months, and this has been working since.
❯ ls -l which ps
-rwsr-xr-x 1 root wheel 170816 Aug 4 06:31 /bin/ps
I haven't updated anything else that I know of since this was last working.
### Further weirdness
After a tty starts losing keystrokes, if it is killed via tmux :kill-window
rather than exiting normally, then other things start hanging until reboot:
- brew
(which is run to check openssl version during bashrc run) sometimes starts hanging and cannot be killed with ^C or stopped with ^Z until after rebooting, which blocks new terminals from starting.
- sudo dmesg
hangs and cannot be killed with ^C or stopped with ^Z until after rebooting.
- ps -ef
outputs some processes but then hangs. Unlike the others, it _can_ be killed with ^C.
[Related GitHub issue](https://github.com/christoomey/vim-tmux-navigator/issues/417)
Asked by Edward Anderson
(243 rep)
Nov 21, 2024, 07:16 PM
Last activity: Feb 4, 2025, 07:18 PM
Last activity: Feb 4, 2025, 07:18 PM