我想让我的程序永远锁定我的第一个想法是:
threadDelay (maxBound :: Int)
给出了一些虚假的警告:
Prelude> import Control.Concurrent
Prelude Control.Concurrent> threadDelay 10
Prelude Control.Concurrent> threadDelay (maxBound :: Int)
<interactive>: c_poll: invalid argument (Invalid argument)
<interactive>: ioManagerWakeup: write: Bad file descriptor
是我做错了还是GHC做错了?
这似乎是一个已知的GHC错误,已经取得了一些进展(尽管并非所有配置似乎都已修复)。
同时,您可以使用forever (threadDelay (2^20))
或类似的方法作为解决方案;2^20
应该离maxBound
足够远,以避免此错误,并且在几个周期内每秒唤醒一次,在您的系统上应该非常容易。