joeyh · GitHub

    -- don't hold the MVar while we call c_waitForProcess...
    -- (XXX but there's a small race window here during which another
    -- thread could close the handle or call waitForProcess)

This is a small race condition indeed, but today I managed to stumble over it, on a Linux system. I have a situation where 2 threads both need to wait for the same process to exit, so both call waitForProcess. One of the threads would then fairly reliably crash with "waitForProcess: does not exist (No child processes)"

Of course, I can work around it in my code by adding my own locking so only 1 thread calls waitForProcess on a process at a time. It could be similarly fixed in System.Process.. add another MVar to ProcessHandle, and make waitForProcess use it to prevent concurrent calls to c_waitForProcess

Read the original on github.com ↗