re-opening a closed stdin?

Bernard James POPE bjpop@cs.mu.OZ.AU
Wed, 20 Nov 2002 17:14:00 +1100 (EST)


Hi all,

There's probably a really obvious answer to this, but I can't find it.

Is there any way in GHC to reopen stdin if it has been closed?

You may wonder why I'd want this. Well I'm writing a debugger
for Haskell 98 (*) and my debugger wants to do some interaction on the terminal
_after_ the user's program has run. If the user's program puts stdin into
a closed or semi-closed state then that causes trouble for my debugger.

What I'd like to do is close stdin after the end of the user's program,
flush any input waiting in the buffer, then reopen it fresh for reading.

If this can't be easily done perhaps there is another solution you can think
of.

(*) www.cs.mu.oz.au/~bjpop/buddha/ 

Cheers,
Bernie.