Kill a shell created by vim when ctrl-C is not working

I am writing some threaded python code in vim. When I run my tests,

:! py.test test_me.py

Sometimes they freeze and cannot be killed with ctrl-C. So I need to use vim (actually the wrapper where the tests are run) and pkill py.test

. Is there a better way to kill the dangling test suite?

I tried to match :map ,k:! pkill py.test

, but it didn't work as while running the tests my login goes to the shell running the test, not vim.

EDIT: I'm looking for a way to kill a test process that is faster, than ctrl-Z

, pkill py.test

, fg

<cr>

, to go back to editing. Ideally just a hotkey.

+3


source to share


1 answer


When you do :!

in Vim, you are effectively putting Vim in the background, and the current process, in this case py.test

, receives focus. This means that you cannot tell Vim to kill the process for you, since Vim is not receiving any keystrokes from you.

Ctrl- Zputs Vim in the background at runtime py.test

because Vim is the parent process py.test

. So the shell goes through the chain, then puts all the children as well as the parent in the background.



I would suggest opening another terminal window and doing all your homework.

+1


source







All Articles