In a (gnome) terminal, if I cat
a file which turns out to be much too long, I can always press Ctrl–c to interrupt.
However, in tmux
, when the same happens, it takes long for the signal produced by the Ctrl–c keypress to reach the server, and until that happens, the server is busy with this output, and I'm unable to do anything but watching the flood (or using a different terminal).
This is somewhat similar to the problem described here.
I do not wish to restart the terminal, the server, or even the specific tmux
window/pane; using less
is a smart habit, but I'm asking here about how to solve problems that already occured, not how to be smart and avoiding them by thinking before acting… there will always be surprises!
So, is there a way to let the terminal stop the floods, discard the sent data, etc.? Anything I can do to release myself from these annoying minutes of watching characters on my screen?
Best Answer
Two proposal
Seldom in case like this CTRL+z is more effective than CTRL+c: it answers faster. After that you suspend the command you can kill it with
kill %1
or whatever is the job number. In the hope that you are still able to read anything from the screen (a flooding random binary text can easily mess up your characters set).In another terminal you can ask
pgrep cat
(ifcat
was the command invoked) and identify thecat
process is using your cpu or bypstree
:pgrep cat | awk '{print "pstree -sp "$1}' | sh | grep tmux
answer with an output like
init(1)---lightdm(1428)---lightdm(2518)---init(2534)---tmux(22425)---bash(22426)---cat(22532)
In this case, after you have only to
kill
thecat
PID
:kill 22532
Note:
less
is safer.