diff options
Diffstat (limited to 'testsuite/tests/lib/IO/hDuplicateTo001.hs')
-rw-r--r-- | testsuite/tests/lib/IO/hDuplicateTo001.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/lib/IO/hDuplicateTo001.hs b/testsuite/tests/lib/IO/hDuplicateTo001.hs new file mode 100644 index 0000000000..5a1484a012 --- /dev/null +++ b/testsuite/tests/lib/IO/hDuplicateTo001.hs @@ -0,0 +1,24 @@ +import GHC.Handle +import GHC.IOBase +import System.IO +import Control.Concurrent.MVar +import Data.Typeable +import qualified GHC.IO.FD as FD + +main = do + h <- openFile "tmp" WriteMode + hDuplicateTo h stdout + + fdh <- getfd h + fdstdout <- getfd stdout + hPutStrLn stderr ("h: " ++ show (fdh /= fdstdout) ++ "\nstdout: " ++ show fdstdout) + + hClose h + putStrLn "bla" + + +getfd h@(FileHandle _ mvar) = do + withMVar mvar $ \h__@Handle__{haDevice=dev} -> + case cast dev of + Just fd -> return (FD.fdFD fd) + Nothing -> error "getfd" |