summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2022-05-28 00:27:15 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2022-07-05 11:03:48 +0100
commit7018fd3514de70fe5881c8824be1e4d2c4f8206a (patch)
tree917f453ebc15d1c35e0f6acb80e6e32068046447
parent5423d84bd9a28fda6dc062cfeb67072b7a26968f (diff)
downloadhaskell-7018fd3514de70fe5881c8824be1e4d2c4f8206a.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)