-
Notifications
You must be signed in to change notification settings - Fork 82
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
Allow async exceptions to pierce masked waitForProcess #101
Conversation
This looks good, I feel much better about the usage of |
@@ -81,6 +81,17 @@ main = do | |||
unless (e1 == ExitSuccess && e2 == ExitSuccess) | |||
$ error "sleep exited with non-zero exit code!" | |||
|
|||
do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test implementation is pretty fragile.
- The sleep value is low enough that the process could legitimately finish before the
waitForProcess
begins - I'd rather not rely on
BlockedIndefinitelyOnMVar
, but instead useonException
toputMVar
a value in the case of an exception - It's worth reporting the
ec
in theRight
case; an exit code of 0 vs 127 will be highly informative, for instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated - how's that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! One last request: can you add a comment to the ChangeLog explaining the change in semantics here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks! |
Hello!
I believe I found a bug in
waitForProcess
. When run in theMaskedInterruptible
state, an async exception doesn't actually bring the thread down.For example, the
typed-process
library exportswithProcess
which is similar towithCreateProcess
, but ends up callingwaitForProcess
in the cleanup action of abracket
.Even though
waitForProcess
is aninterruptible
foreign call, I think what's happening is:waitForProcess
callinterruptible
foreign call, sendsSIGPIPE
(GHC docs)c_waitForProcess
returns-1
with errno =EINTR
MaskedInterruptible
c_waitForProcess
is retried because it's wrapped bythrowErrnoIfMinus1Retry_
So our "interruptible"
waitForProcess
is only half-interrupted :)My fix in this patch is to simply poll for any async exceptions before entering
c_waitForProcess
. Here is some related discussion I had with @snoyberg.Thanks!