GHC's signal handlers break C-c C-c force terminate
GHC RTS has a policy that if it can't neatly shut off after the first C-c, it will forcibly terminate after the second one.
This works all very well, until we reprogram the signal handler:
import Panic
main = do
installSignalHandlers
let f x | x == 0 = 0 :: Int
| otherwise = f (x + 1)
print (f (1 :: Int))
Compile this with
ezyang@sabre:~$ ghc-8.0 --make M.hs -O -package ghc
ezyang@sabre:~$ ./M
^C^C^C^C^C^C^C^C^Z
[1]+ Stopped ./M
ezyang@sabre:~$ kill -9 %1
[1]+ Killed ./M
So yeah, that's a pain. What this means is that if GHC itself infinite loops, you can't ^C it.
Maybe #10686 is exactly this, but my diagnosis doesn't seem to be consistent with their workaround in Leksah. In particular, this program still does not accept C-C:
import Panic
import System.Posix.Signals
(emptySignalSet, sigINT, addSignal, unblockSignals)
main = do
installSignalHandlers
unblockSignals $ addSignal sigINT emptySignalSet
let f x | x == 0 = 0 :: Int
| otherwise = f (x + 1)
print (f (1 :: Int))
#4162 is people asking GHC to NOT install signal handlers unless we are running GHCi; this would also solve the problem.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |