Skip to content

Does not work with async exceptions #107

@ndmitchell

Description

@ndmitchell

Given the code Proc.hs:

import System.Process
import System.Time.Extra

main = do
    (t, e) <- duration $ timeout 2 $ system "sleep 5s"
    print (showDuration t, e)
    (t, e) <- duration $ timeout 2 $ do
        (_, _, _, pid) <- createProcess (proc "sleep" ["5s"])
        waitForProcess pid
    print (showDuration t, e)
    (t, e) <- duration $ timeout 2 $ do
        withCreateProcess (proc "sleep" ["5s"]) $ \_ _ _ pid -> waitForProcess pid
    print (showDuration t, e)

I observe:

C:\Neil\temp>ghc Proc.hs -package=process-1.6.2.0 && proc
[1 of 1] Compiling Main             ( Proc.hs, Proc.o )
Linking Proc.exe ...
("5.06s",Just ExitSuccess)
("5.05s",Just ExitSuccess)
("5.04s",Just ExitSuccess)

C:\Neil\temp>ghc Proc.hs -package=process-1.6.2.0 -threaded && proc
[1 of 1] Compiling Main             ( Proc.hs, Proc.o )
Linking Proc.exe ...
("5.48s",Nothing)
("5.49s",Nothing)
proc: terminateProcess: permission denied (Permission denied)

Running Windows 10, 64bit GHC 8.2.1, process 1.6.2.0. Requires the extra library to be installed and the sleep binary to be on %PATH%. I would expect all these functions to die around 2s, but none of the timeouts are effective.

Originally found when debugging an upstream bug in Shake: ndmitchell/shake#538

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions