[Haskell-cafe] Why is GHCi so hard to kill?
anselm.scholl at tu-harburg.de
Thu May 18 08:07:45 UTC 2017
I think the reason is that no memory allocation occurs in the loop you
are trying to interrupt. Thus, the RTS can not stop the Haskell thread
to terminate the program after catching the signal.
You can only stop a Haskell thread if you are at a safe-point (i.e.
memory allocation). If you call a function like 'last', which is already
compiled, you get this behavior (you can kill it if you define last in
ghci itself, because then it is interpreted instead of using the
compiled version). There is a flag (-fno-omit-yields) to compile a
module with additional safe-points if there is no memory allocation
going on in a loop, but base is build without it, so you get the
behavior you observe.
On 05/18/2017 09:09 AM, Jeremy Henty wrote:
> If I put ghci into a loop by entering "last $ repeat ()" then the
> process is impossible to interrupt or kill except with "kill -KILL".
> (Although it can be stopped with Ctrl-Z.) "kill -TERM" does not work.
> The same is true if I run a runhaskell script containing "main =
> putStrLn $ show $ last $ repeat $ ()".
> Is there a reason for ghci being so unkillable? It is generally
> considered a bad idea for a program to ignore the TERM signal.
> (Details: Debian Linux Jessie 8.8, GHC 8.0.2 (built from source).)
> Jeremy Henty
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 488 bytes
Desc: OpenPGP digital signature
More information about the Haskell-Cafe