-
Notifications
You must be signed in to change notification settings - Fork 89
Allow async exceptions to pierce masked waitForProcess #101
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
Conversation
|
This looks good, I feel much better about the usage of |
| 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
waitForProcessbegins - I'd rather not rely on
BlockedIndefinitelyOnMVar, but instead useonExceptiontoputMVara value in the case of an exception - It's worth reporting the
ecin theRightcase; 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 theMaskedInterruptiblestate, an async exception doesn't actually bring the thread down.For example, the
typed-processlibrary exportswithProcesswhich is similar towithCreateProcess, but ends up callingwaitForProcessin the cleanup action of abracket.Even though
waitForProcessis aninterruptibleforeign call, I think what's happening is:waitForProcesscallinterruptibleforeign call, sendsSIGPIPE(GHC docs)c_waitForProcessreturns-1with errno =EINTRMaskedInterruptiblec_waitForProcessis retried because it's wrapped bythrowErrnoIfMinus1Retry_So our "interruptible"
waitForProcessis 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!