【问题标题】:What to do when Emacs 23 Haskell compilation (C-c C-l) goes into unending process?Emacs 23 Haskell 编译(C-c C-l)进入无休止的过程怎么办?
【发布时间】:2012-08-03 23:19:22
【问题描述】:

很多时候,当我尝试编译.hs 文件时,Emacs 23 Haskell 模式进入一个无休止的过程并且没有显示任何响应。唯一发生的事情是光标变成了一个圆圈,并且在圆圈内,点开始盘旋。

避免这种情况的最佳方法是什么?如果我陷入这种境地,我该如何脱身?目前,我重新启动计算机。请指导。

最近发生了以下代码:

import Control.Monad
import Data.Char
main = do
  putStrLn "This is an addition"
  contents <- getContents
  putStrLn $ (shortLinesOnly contents)
  shortLinesOnly :: String -> String
shortLinesOnly input =
  allLines = lines input
   shortLines = filter (\line -> length line < 10) allLines
               res = unlines shortLines
                     in result

【问题讨论】:

  • 你有没有试过在 emacs 中按三下退出键,这会中止当前的活动?

标签: haskell emacs haskell-platform haskell-mode


【解决方案1】:

也许找到进行编译的函数并将其包装成类似这样的函数是有意义的:

(with-local-quit
  (with-timeout (60 (error "The process didn't finish in 60 seconds"))
     ;; do the calls to the compiler here
     ))

如果这还没有完成。如果这已经完成,那么,正如illusionoflife 建议的那样,您应该能够使用 C-g 中断该过程。

但是,有时 Emacs 可能会变得太慢或太无响应(系统可能会为其启动的进程赋予非常高的优先级,因此您将不得不等待很长时间,直到控件从阻塞进程返回到 Emacs高优先级)。不过,这还不是重新启动计算机的原因。在 Linux 上,您可能在运行级别 3 中运行,在这种情况下,您可以执行 Ctrl+Alt+1 或任何小于运行 X-server 的 shell 的数字,然后执行

$ ps aux | grep "my process name"

这将为您打印有关该过程的一些详细信息,从它的 id 开始,给定您可以执行的 id:

$ kill id

或者,您可以杀死所有 emacs 实例以及由此产生的所有进程:

$ killall emacs

【讨论】:

    【解决方案2】:

    使用C-g。 您可以使用它来停止任何同步过程,无论是内部的还是外部的。

    【讨论】:

    • 奇怪。如果我从 emacs 同步运行 okular,emacs 就会变得不负责任。 C-g 杀死 okular。
    • 运行占用 100% CPU 的计算时会出现问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    相关资源
    最近更新 更多