Ticket #929 (closed merge: fixed)

Opened 7 years ago

Last modified 5 years ago

Strange buffering behaviour in GHCi

Reported by: simonmar Owned by: igloo
Priority: normal Milestone: 6.6.1
Component: GHCi Version: 6.5
Keywords: Cc: clifford.beshers@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Reported by Clifford Beshers on haskell@…:

ghci starts with NoBuffering behavior, even though the mode appears to be LineBuffering. Setting it once fixes the problem.

I've included a ghci session that demonstrates the bug by showing the change in behavior when pressing Control-D in response to each call to getLine. The results are identical for 6.4.1 and 6.6 rc1.

  ___         ___ _
 / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |      GHC Interactive, version 6.4.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base-1.0 ... linking ... done.
Prelude> :m +System.IO
Prelude System.IO> hGetBuffering stdin >>= print
LineBuffering
Prelude System.IO> getLine >>= print
^D
"\EOT"
Prelude System.IO> hSetBuffering stdin NoBuffering >> hGetBuffering stdin >>= print
NoBuffering
Prelude System.IO> getLine >>= print
^D
"\EOT"
Prelude System.IO> hSetBuffering stdin LineBuffering >> hGetBuffering stdin >>= print
LineBuffering
Prelude System.IO> getLine >>= print
*** Exception: <stdin>: hGetLine: end of file
Prelude System.IO>



  ___         ___ _
 / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |      GHC Interactive, version 6.5.20060831, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> :m +System.IO
Prelude System.IO> hGetBuffering stdin >>= print
LineBuffering
Prelude System.IO> getLine >>= print
^D
"\EOT"
Prelude System.IO> hSetBuffering stdin NoBuffering >> hGetBuffering stdin >>= print
NoBuffering
Prelude System.IO> getLine >>= print
^D
"\EOT"
Prelude System.IO> hSetBuffering stdin LineBuffering >> hGetBuffering stdin >>= print
LineBuffering
Prelude System.IO> getLine >>= print
*** Exception: <stdin>: hGetLine: end of file
Prelude System.IO> 

Change History

Changed 6 years ago by igloo

  • owner set to igloo

Changed 6 years ago by igloo

  • type changed from bug to merge

Fixed by

Mon Jan 8 16:28:38 GMT 2007 Ian Lynagh <igloo@…>

  • When setting stdout and stderr to NoBuffering? in GHCi, do stdin too. Fixes trac #929. Merge to 6.6 branch.

in the HEAD.

Changed 6 years ago by igloo

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

Merged to the 6.6 branch.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.