doctest icon indicating copy to clipboard operation
doctest copied to clipboard

[RFC] Terminate ghci process before waiting for it.

Open fisx opened this issue 9 years ago • 2 comments

May be related to https://github.com/hspec/sensei/issues/30.

This change is based on the unconfirmed theory that pressing ^C repeatedly sometimes leaves ghci processes running, with the same symptoms as described in the comment near this change.

Breaks the test suite, but it does have the expected and desired effect that the reaction on ^C is immediate.

Before I look at the test suite: is this worth investigating?

thanks-

fisx avatar Feb 12 '16 06:02 fisx

@fisx Is the assumption something like:

  1. The user presses ctrl-c, doctest receives SIGINT but the forked ghci does not receive SIGINT
  2. ghci is still busy with something so closing stdin does not result immediate termination and waitForProcess blocks
  3. The user presses ctrl-c again, doctest gets killed but the ghci process is still there

By doing a terminateProcess first, ghci gets interrupted ==> closing stdin has the intended effect of terminating ghci and waitForProcess does not block any more. Is that your reasoning?

I think for me to understand all the details I would need to read up on POSIX process groups and signal handling again.

In addition I'm puzzled whether masking any async exception until ghci is terminated would be of any benefit.

sol avatar Feb 13 '16 07:02 sol

[...] Is that your reasoning?

Yes, thanks for the much better explanation.

In addition I'm puzzled whether masking any async exception until ghci is terminated would be of any benefit.

You mean, catching and dropping extra SIGINTs? that would certainly solve the problem of ghci killing my machine every now and then.

The advantage of my idea is that the first ^C has an immediate effect.

Of course all this is a lot less relevant if you only have test suites that run less than 3 seconds. :-)

fisx avatar Feb 13 '16 08:02 fisx