19.5 C
New York
Wednesday, June 18, 2025

Operating `ps -t /dev/` began inflicting the required terminal to cease receiving most keystrokes


Particular Drawback

Operating ps -t /dev/ not too long ago began inflicting the related terminal to cease receiving some keystrokes. I can not fathom why this began taking place now, with none software program updates that I am conscious of.

After working the ps command, most keystrokes will not make it by way of to this shell or no matter program is working within the tty (e.g. if you happen to run it from in a vim subshell). Solely a subset make it by way of, requiring repeating keypresses a number of instances earlier than they register, as if eaten by one other course of. Repeated runs of ps -t exacerbate the issue additional.

To Reproduce

Notably, I can solely reproduce this on certainly one of my machines.

ps -t $(tty)

A big share of keystrokes are dropped from the TTY now.

It may be run on the present TTY or one other TTY. The goal TTY is affected.

To get better from this, exit the TTY utilizing Ctrl+D or exit. (Keystrokes will should be entered repeatedly.)

I would have an interest to listen to who can and can’t reproduce this.

Why That is Wanted

vim-tmux-navigator makes use of this tmux configuration to detect whether or not vim is the energetic course of within the present tmux pane, with a view to permit seamless navigation inside 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"

Variations

I am working MacOS 14.6.1.

The /bin/ps executable hasn’t been touched in a number of 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 have not up to date anything that I do know of since this was final working.

Additional weirdness

After a tty begins shedding keystrokes, whether it is killed through tmux :kill-window reasonably than exiting usually, then different issues begin hanging till reboot:

  • brew (which is run to examine openssl model throughout bashrc run) generally begins hanging and can’t be killed with ^C or stopped with ^Z till after rebooting, which blocks new terminals from beginning.
  • sudo dmesg hangs and can’t be killed with ^C or stopped with ^Z till after rebooting.
  • ps -ef outputs some processes however then hangs. In contrast to the others, it can be killed with ^C.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles