Ticket #9168: Broken.hs

File Broken.hs, 632 bytes (added by rwbarton, 15 months ago)
Line 
1module Broken where
2
3import Control.Monad
4import System.IO
5
6import System.FilePath.Posix
7
8import GHC.IO.Handle.FD (openFileBlocking)
9
10open :: FilePath -> IO Handle
11open filename = openFileBlocking filename ReadWriteMode
12
13openABunchOfFiles :: Int -> IO [Handle]
14openABunchOfFiles n = do
15  let aBunchOfFiles = fmap (("stressIO" </>) . show) [1 .. n]
16  mapM open aBunchOfFiles
17
18openAndCloseABunchOfFiles :: Int -> IO ()
19openAndCloseABunchOfFiles n = do
20  hs <- openABunchOfFiles n
21  forM_ hs $ \h -> do
22    hPutStrLn h (show "This shouldn't be printed to the console")
23    hClose h
24
25main :: IO ()
26main = openAndCloseABunchOfFiles 2000