[darcs-users] bug report: "Fail: <stdin>: hSetBuffering: unsupported operation (Illegal seek)"

David Brown darcs at davidb.org
Fri May 7 16:03:52 UTC 2004


On Fri, May 07, 2004 at 06:56:16AM -0400, David Roundy wrote:

> > Fail: <stdin>: hSetBuffering: unsupported operation (Illegal seek)
> 
> I haven't been able to reproduce this.  I know I've seen it before though.
> :( So if you (or anyone else) has a suggestion how I could reproduce (and
> therefore fix, or at least identify) this bug, that would be great.

It is a GHC library bug, but it is mentioned in a TODO in the source.
In GHC/Handle.lhs:

  TODO:
  ...
  hSetBuffering: can't change buffering on a stream,
       when the read buffer is non-empty? (no way to flush the buffer)

It likely happens when you change to or from unbuffered mode and there
are already characters typed ahead.  The seek isn't supposed to happen
on a tty, though.  It is trivial to reproduce:

  module Main where
  import System.IO
  main :: IO ()
  main = do
    getChar
    hSetBuffering stdin NoBuffering
    getChar
    return ()

Build this, run it, and just type a few characters on stdin, and press
return.

What's real interesting is that this doesn't break on OSX (both have
6.2 of ghc).

Dave Brown




More information about the darcs-users mailing list