Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • testsuite/tests/process/T3994.hs
    1 1
     module Main where
    
    2 2
     
    
    3 3
     import Control.Concurrent
    
    4
    +import Control.Exception
    
    5
    +import Control.Monad
    
    4 6
     import System.IO
    
    7
    +import System.IO.Error
    
    5 8
     import System.Process
    
    6 9
     
    
    7 10
     main :: IO ()
    
    ... ... @@ -9,14 +12,24 @@ main = do (_,Just hout,_,p) <- createProcess (proc "./T3994app" ["start", "10000
    9 12
                                 { std_out = CreatePipe, create_group = True }
    
    10 13
               start <- hGetLine hout
    
    11 14
               putStrLn start
    
    12
    -          interruptProcessGroupOf p
    
    13
    -          t <- myThreadId
    
    14
    -               -- timeout
    
    15
    -          forkIO $ do
    
    16
    -            threadDelay 5000000
    
    17
    -            putStrLn "Interrupting a Running Process Failed"
    
    18
    -            hFlush stdout
    
    19
    -            killThread t
    
    20
    -          waitForProcess p
    
    15
    +
    
    16
    +          -- On FreeBSD if we're _really_ unlucky with scheduling, then the
    
    17
    +          -- call to interruptProcessGroupOf can fail due to the process
    
    18
    +          -- having already terminated (despite it running for at least 10ms!)
    
    19
    +          -- If so, we just skip doing anything rather than fail the test,
    
    20
    +          -- since this isn't our fault and is rare and scheduling dependent.
    
    21
    +          -- See #27512 and https://reviews.freebsd.org/D58393
    
    22
    +          handleJust (guard . isDoesNotExistError) (\_ -> return ()) $ do
    
    23
    +            interruptProcessGroupOf p
    
    24
    +            t <- myThreadId
    
    25
    +                 -- timeout
    
    26
    +            forkIO $ do
    
    27
    +              threadDelay 5000000
    
    28
    +              putStrLn "Interrupting a Running Process Failed"
    
    29
    +              hFlush stdout
    
    30
    +              killThread t
    
    31
    +            waitForProcess p
    
    32
    +            return ()
    
    33
    +
    
    21 34
               putStrLn "end"
    
    22 35
               return ()