Open
Description
This may be related to #38 (or a duplicate of it), but I am posting because my use case is explicitly using async exceptions.
Here is a simple program that calls readProcess_ and then attempts to cancel it, using the async library:
import Control.Concurrent
import Control.Concurrent.Async
import Control.Exception
import System.Process.Typed
main :: IO ()
main = do
putStrLn "Start"
a <- async $ do
readProcess_ (proc "/bin/sleep" ["1"]) -- Sleep 1 second
threadDelay (20 * 1000) -- Wait 20 milliseconds
putStrLn "Canceling"
cancel a
putStrLn "Waiting"
r <- waitCatch a
print r
Here is the correct output that I expect to see (and I get about 20% of the time):
Start
Canceling
Left AsyncCancelled
But most of the time, I get this unexpected output:
Start
Canceling
Left waitForProcess: does not exist (No child processes)
That is the first bug.
The second bug is that the "cancel" line is not immediate, it seems that it doesn't actually terminate the running process, but always waits for the "sleep" process to complete (I am compiling using -threaded
flag). This delay happens with both output scenarios.
Thank you
Metadata
Metadata
Assignees
Labels
No labels