问题描述
当我启动
ghci> last [0..]
我可以使用Ctrl + C中断它.
I can interrupt it with Ctrl+C.
但是
ghci> last (repeat 0)
不能用Ctrl + C中止. GHCI默默地忽略了击键.
cannot be aborted with Ctrl+C. GHCI silently ignores the keystrokes.
如何在GHCI中中止此命令?是虫子吗?
How to abort this command in GHCI? Is it a bug?
推荐答案
(注意:我使用Linux,并在urxvt或gnome-terminal上运行zsh.如果使用其他操作系统,终端或Shell,则可能这对您来说会有所不同.)
(Caveat lector: I use Linux, and run zsh on urxvt or gnome-terminal. If you use a different operating system, terminal, or shell, it's possible this will work differently for you.)
我通常的处理方式是按Ctrl + Z(将其置于后台,完全暂停执行作为副作用),然后终止该工作.通常是kill %1
,尽管您可以运行jobs
进行仔细检查.
The way I usually handle this is to hit Ctrl+Z (which puts it in the background, pausing execution entirely as a side-effect) then kill the job. Usually this is kill %1
, though you can run jobs
to double-check.
您还可以启动一个新终端并执行killall -9 ghci
之类的操作,但这会带来更高的资源成本:您将产生一些新进程,打开X连接,并执行终端在初始化自身时所做的一切,做它初始化时shell所做的一切,等等.如果遇到这种情况,我经常会发现自己-ghci像疯了似的交换-只是给ghci更多的时间搞砸了.
You can also start a new terminal and do something like killall -9 ghci
, but this has a much higher resource cost: you are spawning a few new processes, opening X connections, doing whatever it is your terminal does when it initializes itself, doing whatever it is your shell does when it initializes itself, etc. If you're in the situation I often find myself in -- ghci is swapping like crazy -- that just gives ghci more time to screw things up.
这篇关于如何中止GHCI中的执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!