From: "Mark J. Reed" Date: 2003-09-19T03:15:15+09:00 Subject: Re: closing stderr On Fri, Sep 19, 2003 at 02:18:35AM +0900, Michael Garriss wrote: > Mark J. Reed wrote: > >Note that you have to assign something open to $stderr before assigning > >to STDERR, or else the assignment to STDERR throws an exception trying to > >print the "already initialized constant" warning and the assignment > >doesn't complete. There is probably a cleaner way of doing this. > > Assign something open? I don't understand. I get a syntax error on > that assignment: What I mean is that this assignment: STDERR = blah Generates a warning: warning: already initialized constant STDERR And that warning message is sent to - where else - $stderr. Which means if $stderr is still pointing to a closed File object at the time you try to assign to STDERR, Ruby tries to send the warning about the assignment, fails to do so because $stderr is closed, and aborts the assignment. (It seems odd that failure to emit a warning would itself be fatal to the surrounding operation, but that's the behavior I'm seeing on final 1.8.0) > bin/ruglyctl:132:in `require': > /usr/www/apache/rugly/lib/rdb_rugly.rb:40: dynamic constant assignment > (SyntaxError) > STDERR = $stderr Hm, I'm not sure what that means. Is this running in mod_ruby? -Mark