summaryrefslogtreecommitdiff
path: root/libraries/base/tests/T12852.hs
blob: 5bf80d5218e3c9caca1bd08770a8027f44ba2fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import GHC.Conc
import GHC.IO
import GHC.IO.FD as FD
import System.Posix.IO
import System.Posix.Types

main = do
  (rfd,wfd) <- createPipe
  (waitread, unregister) <- threadWaitReadSTM rfd
  unregister
  result0 <- atomically $ (fmap (const False) waitread) `orElse` return True
  print result0
  fdWrite wfd "test"
  threadDelay 20000
  result1 <- atomically $ (fmap (const False) waitread) `orElse` return True
  print result1
  (waitread1, _) <- threadWaitReadSTM rfd
  threadDelay 20000
  result2 <- atomically $ (fmap (const True) waitread1) `orElse` return False
  print result2