Skip to content

Commit 2521ee9

Browse files
committed
Fix race condition in PackageTests/NewBuild/CmdRun/Terminate
The "up and running" file was written before the signal handler was installed, so it was possible for the test to kill the subprocess before, leading to a missed "exiting" line in the output. I hope this fixes the sporadic failures we're seeing (haskell#8080).
1 parent 32259a1 commit 2521ee9

File tree

1 file changed

+6
-8
lines changed
  • cabal-testsuite/PackageTests/NewBuild/CmdRun/Terminate

1 file changed

+6
-8
lines changed

cabal-testsuite/PackageTests/NewBuild/CmdRun/Terminate/Main.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import qualified System.Posix.Signals as Signal
44
import System.Exit (exitFailure)
55

66
main = do
7-
writeFile "exe.run" "up and running"
87
mainThreadId <- myThreadId
98
Signal.installHandler Signal.sigTERM (Signal.Catch $ killThread mainThreadId) Nothing
10-
sleep
11-
`finally` putStrLn "exiting"
12-
where
13-
sleep = do
14-
putStrLn "about to sleep"
15-
threadDelay 10000000 -- 10s
16-
putStrLn "done sleeping"
9+
do
10+
putStrLn "about to sleep"
11+
writeFile "exe.run" "up and running"
12+
threadDelay 10000000 -- 10s
13+
putStrLn "done sleeping"
14+
`finally` putStrLn "exiting"

0 commit comments

Comments
 (0)