Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/all.T
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ test('process010', [
test('process011',
[when(opsys('mingw32'), skip), pre_cmd('{compiler} -no-hs-main -o process011_c process011_c.c'), js_broken(22349)],
compile_and_run, [''])

test('process-fork-wait', normal, compile_and_run, [''])
test('T8343', js_broken(22349), compile_and_run, [''])
test('processT251', js_broken(22349), compile_and_run, [''])
42 changes: 42 additions & 0 deletions tests/process-fork-wait.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- | This test verifies that the 'use_process_jobs' feature works as
-- advertised. Specifically: on Windows 'waitForProcess' should not return
-- until all processes created by the child (including those created with
-- @fork@) have exited if 'use_process_jobs' is enabled.
--

module Main where

import Control.Concurrent
import Control.Monad
import System.Environment
import System.IO
import System.Process

main :: IO ()
main = do
args <- getArgs
run args

run :: [String] -> IO ()
run [] = do
putStrLn "starting A"
hFlush stdout
-- Disabling use_process_jobs here will cause waitForProcess to return
-- before the process B invocation has written the test file.
(_,_,_,p) <- createProcess $ (proc "process-fork-wait" ["A"]) { use_process_jobs = True }
void $ waitForProcess p
contents <- readFile "test"
when (contents /= "looks good to me")
$ fail "invalid file contents"
run ["A"] = do
putStrLn "A started"
hFlush stdout
(_,_,_,_) <- createProcess $ (proc "process-fork-wait" ["B"])
return ()
run ["B"] = do
putStrLn "B started"
hFlush stdout
threadDelay (5*1000*1000)
writeFile "test" "looks good to me"
putStrLn "B finished"
run _ = fail "unknown mode"
4 changes: 4 additions & 0 deletions tests/process-fork-wait.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
starting A
A started
B started
B finished