Ticket #31 (closed task: fixed)

Opened 8 years ago

Last modified 7 years ago

Crash when stdin is a terminal but stdout is not.

Reported by: anonymous Owned by:
Priority: major Milestone:
Version: 0.3 Keywords: 03627546


Haskeline seems to perform wrong operations when the standard output is not a terminal. A small test program is attached. Here are the result it produces when using a terminal as standard output ("a" is entered manually):

[glehmann@gbook haskeline]$ runhaskell test.hs
getLine: a
haskeline: a

which seem to be the right behavior. When using a different standard output, the program crash:

[glehmann@gbook haskeline]$ runhaskell test.hs | tee foo
getLine: a
test.hs: getTerminalAttributes: illegal operation (Inappropriate ioctl for device)

and when using a program a standard input, the behavior is the same as getLine, as documented:

[glehmann@gbook haskeline]$ yes | runhaskell test.hs | tee foo
getLine: y

This problem has been found in a darcs test by Eric Kow - see http://bugs.darcs.net/issue1050

Change History

Changed 8 years ago by anonymous

I can't attach the test file, so I put it here - it is quite small:

import System.Console.Haskeline ( runInputT, defaultSettings, getInputLine )
import Data.Maybe ( fromJust )

main :: IO ()
main = do
  -- test with getLine first
  putStr "getLine: "
  res <- getLine
  putStrLn res
  -- and the same with haskeline
  res <- runInputT defaultSettings (getInputLine "haskeline: ")
  putStrLn $ fromJust res

Changed 8 years ago by judah

Thanks for the report! Fixed by:

Wed Sep 10 17:07:27 PDT 2008  judah.jacobson@gmail.com
  * Call getTerminalAttributes on stdInput, not stdOutput.  Fixes the crash in #31.

However I don't think this was what caused the above darcs issue; see #36 instead.

Changed 8 years ago by judah

  • status changed from new to closed
  • resolution set to fixed

Changed 8 years ago by gaetan

That's a great news - thanks a lot! Do you plan to release it soon? If so, it would be possible to re-enable haskeline support by default in the next darcs release :-)

Changed 8 years ago by judah

The haskeline-0.3 release is just waiting on some more thorough testing; it should happen sometime next week, perhaps this weekend if everything works out fine.

And thanks for the motivation; having haskeline enabled by default in darcs is definitely a big incentive!

Changed 7 years ago by judah

  • summary changed from mgxpjrg to Crash when stdin is a terminal but stdout is not.
Note: See TracTickets for help on using tickets.