diff --git a/src/System/Console/Terminal/Windows.hs b/src/System/Console/Terminal/Windows.hs index 962afd7..b4fc4d2 100644 --- a/src/System/Console/Terminal/Windows.hs +++ b/src/System/Console/Terminal/Windows.hs @@ -4,6 +4,7 @@ module System.Console.Terminal.Windows(size) where import System.Console.Terminal.Common import Control.Monad +import Control.Exception (evaluate) import Data.Word import Foreign.Ptr import Foreign.Storable @@ -42,9 +43,12 @@ size = do let stty = (shell "stty size") { std_in = UseHandle stdin , std_out = CreatePipe + , std_err = CreatePipe } - (_, mbStdout, _, rStty) <- createProcess stty + (_, mbStdout, mbStderr, rStty) <- createProcess stty exStty <- waitForProcess rStty + -- Drain stderr by evaluating it fully + maybe (pure ()) ((void . evaluate . length) <=< hGetContents) mbStderr case exStty of ExitFailure _ -> return Nothing ExitSuccess ->