summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/IO/countReaders001.hs
blob: 2648ae77ae40aa779284ce0a8c0960657b3c97a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- test for trac #629. We need to keep track of how many readers
-- there are rather than closing the first read handle causing the
-- lock to be released.

import System.IO
import System.IO.Error

file = "countReaders001.txt"

main = do
  writeFile file "foo"

  h1 <- openFile file ReadMode
  h2 <- openFile file ReadMode
  hClose h1
  tryIOError (openFile file AppendMode) >>= print