Scripsit illa aut ille obert Klemme¥© <bob.news / gmx.net>: > "Michael Garriss" <mgarriss / earthlink.net> schrieb im Newsbeitrag news:3F69D414.70008 / earthlink.net... > > I would like to prevent some output that is going to stderr during a > > call to a third party lib just during that call. My first guess was: > > > > STDERR.close_write > > ThirdPartyLib::call_some_annoying_function > > STDERR.???? > > > > I guess you can see my problem. Can anyone give me a lead on this? [...] > $stderr = StringIO.new > STDERR = $stderr Are you sure it occupies file descriptor 2 (which external libraries normally use)? def without_stderr(&block) save = $stderr.dup() $stderr.close() # this will affect STDERR, too. begin yield ensure $stderr = save.dup() # SIDE EFFECT: the file descriptor STDERR points to will be valid again end end However, this routine assumes that all file descriptors before $stderr are used. This is the case unless $stdin or $stdout have been closed. Is there something like dup2() in Ruby? -- The only thing that Babelfish is good at is proving that Vogons are great poets. Josef 'Jupp' Schugt in japan.anime.evangelion