I was slightly confused by:
% vim tmp
zsh: suspended vim tmp
% kill %1
% jobs
[1] + suspended vim tmp
% kill -SIGINT %1
% jobs
[1] + suspended vim tmp
% kill -INT %1
% jobs
[1] + suspended vim tmp
So I resigned to just "do it myself" and wonder why later:
% fg
[1] - continued vim tmp
Vim: Caught deadly signal TERM
Vim: Finished.
zsh: terminated vim tmp
%
Oh!
Makes sense really, now that I think about it, that vim
has to be running in order for it's signal handler to be told to quit, and to do so.
But obviously not what I intended.
Is there a way to "wake and quit" in a single command? i.e., a built-in alias for kill %N && fg %N
?
Why does resuming in the background not work? If I bg
instead of fg
, Vim stays alive until I fg
, which sort of breaks my above intuition.
Best Answer
vi-vi-vi
is of the devil. You must kill it with fire. OrSIGKILL
:The builtin
kill
s are kind enough to sendSIGCONT
to suspended processes so that you don't have to do it yourself, but that won't help if the process blocks the signal you're sending or if handling the signal causes the processes to become suspended again (if a background process tries to read from the terminal, by default, it'll be sentSIGTTIN
, which suspends the process if unhandled).