process
process copied to clipboard
`waitForProcess` throws a `NoSuchThing` exception if the process completes too quickly.
I have observed that if you call waitForProcess
and the process has already completed, an exception is raised. This can be rather surprising since if you launch a process and it doesn't take a lot of time you can be unable to check whether or not it completed successfully by looking at the exit code.
I've never seen this, despite having test cases that include very short lived processes like true
. Can you provide a repo, including exact versions of libraries and GHC, as well as OS? Ideally a Stack script would lock everything down.
It's possible that it isn't related to it being short lived, that part is speculation. The observed behavior is that if I launch several (4) processes using typed-process
with conduit
output streams via async
actions, every so often one of them will fail on withProcessTerm
or the variant withProcessTerm_
. When I switch to withProcessWait
, it never causes this particular issue.
When I drilled down, the exception being raised was that it was blocked indefinitely on an STM transaction and I figured out that this was due to waitExitCodeSTM
blocking on a TMVar that would never be filled. The root cause of this is because waitForProcess
raises a NoSuchThing variant of IOError and this would cascade to the ExitCode
not being retrieved and consequently not fed to the TMVar. I was able to confirm this when I used the non-exit code checking variant. In this case the exception changed from STM blocking to waitForProcess
"No child processes", which is called from within the various withProcessTerm
calls.
I filed this bug here because I think the underlying issue is that waitForProcess
seems like it should always succeed in this context, but it is possible the bug is in typed-process
instead.
I will put together a small repo that can still produce this error today.
Any further updates on this, @ProofOfKeags ?
I completely forgot about this. No updates as of right now. Not sure when I'll be able to get to it.