Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We are silently ignoring UserInterrupts on delegate_ctlc #73

Open
sol opened this issue May 23, 2023 · 0 comments
Open

We are silently ignoring UserInterrupts on delegate_ctlc #73

sol opened this issue May 23, 2023 · 0 comments

Comments

@sol
Copy link
Contributor

sol commented May 23, 2023

When delegate_ctlc is used then waitForProcess throws UserInterrupt if the child terminated due to ctrl-c.

However, we ignore any such exceptions.

  1. We call waitForProcess here
    then P.waitForProcess pHandle
  2. Any exceptions will then be turned into a Left-value here
    eec <- waitCatch waitingThread
  3. Finally we ignore them here (wrongly assuming that it can only be an AsyncCancelled)

#70 addresses this specific problem.

However, we also deadlock on waitExitCode with delegate_ctlc on ctrl-c, as in that case pExitCode will be left empty:

$ cabal exec -- ghci -isrc src/System/Process/Typed.hs
ghci> withProcessWait (setDelegateCtlc True $ proc "sleep" ["100"]) $ \ p -> waitExitCode p
^C
*** Exception: thread blocked indefinitely in an STM transaction

(I'm using cabal exec instead of stack exec here, as stack exec fails with a different error. I assume that this is due to stack using typed-process itself and hence it is itself affected by this bug and #69.)

You could address this by say storing an Either SomeException ExitCode in pExitCode, but async already solved this for us. So I think we should rely on async instead.

Once we are done with #70, I'll open a PR along the lines of sol@3e37a48, which addresses this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant