Hi, Why doesn't this program start reading from one fifo until the second fifo gets opened (with cat), too? (It doesn't matter which fifo is opened first.) Why doesn't it print "forked" before "fifo1" is opened? After both fifos are open, it works as expected.
I have ghc 6.6-3 on debian-linux (testing) Sebastian Setzer ------------------------------------------------------------------ -- Compile: ghc twofifo.hs -o twofifo -threaded -package unix-1.0 -- Usage: -- mkfifo fifo1 -- mkfifo fifo1 -- ./twofifo -- in two separate xterms: -- cat > fifo1 -- ... -- cat > fifo2 -- ... import System.IO import System.Posix.IO import System.Posix.Types import Control.Concurrent main :: IO() main = do f1Thread <- forkOS (openAndShowFile "fifo1") print "forked" hFlush stdout openAndShowFile "fifo2" openAndShowFile :: String -> IO() openAndShowFile name = do fd <- openFd name ReadOnly Nothing defaultFileFlags showFile name fd showFile :: String -> Fd -> IO() showFile name fd = do threadWaitRead fd (s, count) <- fdRead fd 1024 print (name ++ ": " ++ s) hFlush stdout showFile name fd _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell