简体   繁体   English

当ctrl-C不起作用时,杀死由vim创建的shell

[英]kill a shell created by vim when ctrl-C doesn't work

I'm writing some threaded python code in vim. 我正在vim中编写一些线程python代码。 When I run my tests, with 当我运行我的测试时,用

:! py.test test_me.py

Sometimes they hang and cannot be killed with ctrl-C. 有时它们会挂起,不能用ctrl-C杀死。 So I have to background vim (actually the shell the tests are running in) and pkill py.test . 所以我必须背景vim(实际上运行测试的shell)和pkill py.test Is there a better way to kill the hanging test suite? 有没有更好的方法来杀死悬挂的测试套件?

I tried mapping :map ,k:! pkill py.test 我试过映射:map ,k:! pkill py.test :map ,k:! pkill py.test but this doesn't work since while the tests are running my input is going to the shell running the test, not vim. :map ,k:! pkill py.test但这不起作用,因为在测试运行时我的输入是运行测试的shell,而不是vim。

EDIT: I'm looking for a way to kill the test process that is quicker than ctrl-Z , pkill py.test , fg <cr> to return to editing. 编辑:我正在寻找一种方法来杀死比ctrl-Z更快的测试过程, pkill py.testfg <cr>返回编辑。 Ideally just a hotkey. 理想情况下只是一个热键。

When you do :! 当你这样做:! in Vim, you effectively put Vim into background and the running process, in this case py.test , gets the focus. 在Vim中,你有效地将Vim置于后台,并且运行过程(在本例中为py.test )得到了关注。 That means you can't tell Vim to kill the process for you since Vim is not getting keystrokes from you. 这意味着你无法告诉Vim为你杀死进程,因为Vim没有从你那里获得击键。

Ctrl - Z puts Vim into background while running py.test because Vim is the parent process of py.test . 按Ctrl - z把Vim的进入后台运行的同时py.test因为Vim是的父进程py.test Thus the shell goes through the chain then puts all children as well as the parent into background. 因此,shell通过链然后将所有子项以及父项放入后台。

I would suggest that you open another terminal window and do all the housekeeping chores there. 我建议你打开另一个终端窗口并在那里做所有家务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM