Skip to content

hSetBuffering NoBuffering and getChar don't work properly on Windows

With this program:

import System.IO

main = do { hSetBuffering stdin NoBuffering; run }
run = do { getChar; putStrLn "yes"; run }

if I type

abc<enter>def<enter><control-C>

then:

On Linux and OS X I get the desired output:

$ ./q
ayes
byes
cyes

yes
dyes
eyes
fyes

yes
^Cq: interrupted

In an MSYS window I get:

$ ./q
abc
def

In a cygwin window or a cmd windows I get:

$ ./q
abc
yes
yes
yes
yes
def
yes
yes
yes
yes

and the program doesn't die.

SSHing into cygwin I get:

$ ./q
abc
def
Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information