summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2022-05-28 00:27:15 +0100
committerZubin Duggal <zubin.duggal@gmail.com>2022-07-14 14:39:37 +0530
commitac064f37a0490ac4b885a185726ec13e042c9e9d (patch)
treed356ab04cbc2521b344c12d5437ce11bcacc4e78
parentc48d7704cc433107c65431d27b0fe6da1fb1161d (diff)
downloadhaskell-ac064f37a0490ac4b885a185726ec13e042c9e9d.tar.gz
winio: Add support to console handles to handleToHANDLE
(cherry picked from commit 31c214cc9d3873b7d1bf4751700cc6c7da09e11d)
-rw-r--r--libraries/base/GHC/IO/Handle/Windows.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/libraries/base/GHC/IO/Handle/Windows.hs b/libraries/base/GHC/IO/Handle/Windows.hs
index 0666ce42e3..9fd1c54d49 100644
--- a/libraries/base/GHC/IO/Handle/Windows.hs
+++ b/libraries/base/GHC/IO/Handle/Windows.hs
@@ -217,9 +217,11 @@ handleToHANDLE :: Handle -> IO Win.HANDLE
handleToHANDLE h = case h of
FileHandle _ mv -> do
Handle__{haDevice = dev} <- readMVar mv
- case (cast dev :: Maybe (Win.Io Win.NativeHandle)) of
- Just hwnd -> return $ Win.toHANDLE hwnd
- Nothing -> throwErr "not a file HANDLE"
+ case (cast dev :: Maybe (Win.Io Win.NativeHandle),
+ cast dev :: Maybe (Win.Io Win.ConsoleHandle)) of
+ (Just hwnd, Nothing) -> return $ Win.toHANDLE hwnd
+ (Nothing, Just hwnd) -> return $ Win.toHANDLE hwnd
+ _ -> throwErr "not a file HANDLE"
DuplexHandle{} -> throwErr "not a file handle"
where
throwErr msg = ioException $ IOError (Just h)