[plt-scheme] mzscheme enters infinite loop when unable to write to stdout

From: Andrew Wilcox (andrew.wilcox at gmail.com)
Date: Mon Jun 22 13:10:38 EDT 2009

On Mon, Jun 22, 2009 at 8:57 AM, Eli Barzilay<eli at barzilay.org> wrote:
> On Jun 22, Matthew Flatt wrote:
>> At Sun, 21 Jun 2009 12:08:05 +0100, "Paulo J. Matos" wrote:
>> > On Sat, 2009-06-20 at 20:38 -0400, Andrew Wilcox wrote:
>> > > mzscheme enters an infinite loop printing "error writing to stream
>> > > port" at the REPL if it is unable to write to stdout.  (the odd
>> > > position of the ">" prompt in the output is due to redirecting stdout
>> > > to a pipe).
>> > >
>> >
>> > I confirm this issue also in latest 4.2.
>>
>> I'm not sure there's a good solution to this. (This is an old issue.)
>>
>> The problem is that the exception is coming from deep inside `write'. A
>> REPL generally shouldn't not exit just because printing a result
>> failed. It might be that something went wrong calling a custom write
>> handler, or maybe there was a transient error on the output port, and
>> so the programmer might want to try again.

> mz -e '(parameterize ([exit-on-closed-output #t])
>          (for ([i (in-naturals)]) (printf "~s\n" i)))' | head -5

Personally, I don't need the REPL to abort or exit if it isn't able to
write.  I'd be happy that if the REPL wasn't able to print to stdout,
it would print some error on stderr, and if it wasn't able to print to
stderr, it would just ignore that error.  And return to the prompt,
waiting for more input like it always does... just not successfully
printing anything, if the error turns out not to be transient.  For
myself, I don't need it to do anything more.


Posted on the users mailing list.