Re: Can you temporarily turn off STDERR?

IO#reopen to take

class IO
begin
end
puts “normal stuff 2”
File.open(‘error_log_4’, ‘w’) do |log_file|
$stderr.reopen(‘error_log_5’, ‘w’) do
$stderr.puts “Stuff on error 5”
puts “normal stuff 5”
raise “This message courtesy of raise”
end
rescue => e
puts e
end

end

Awesome. Now, can we break this with threads? Aredridel?

Of course, I wonder if IO#reopen is thread safe anyway, regardless of
the block. I’ve never seriously tested it.

Regards,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

Awesome. Now, can we break this with threads? Aredridel?

Of course, I wonder if IO#reopen is thread safe anyway, regardless of
the block. I’ve never seriously tested it.

Well, it’s thread-safe, but it’s process-global. It’d get turned off for
the duration of the block, regardless of other threads.