I _think_ there may be a bug in set_outfile:
static void
set_outfile(val, var, orig, stdf)
VALUE val;
VALUE *var;
VALUE orig;
FILE *stdf;
{
OpenFile *fptr;
FILE *f;
if (val == *var) return;
if (TYPE(*var) == T_FILE) {
rb_io_flush(*var); // <<<<<<<<<<
}
I think this should check to see if the file is closed before doing
the flush.
begin
$stderr.close
$stderr = nil
rescue
puts "Exception"
puts $!
puts $!.backtrace
end
#=>
Exception
closed stream
t.rb:3
However, I may well be wrong... :)
Dave