From: "Iñaki Baz Castillo" Date: 2010-01-16T08:45:15+09:00 Subject: Re: How to know if $stderr is reopened to /dev/null El Sábado, 16 de Enero de 2010, Justin Collins escribió: > Iñaki Baz Castillo wrote: > > Hi, how could I know if $stderr has been redirected to /dev/null? > > This is, imagine a program does: > > > > $stderr.reopen "/dev/null" > > > > And later I want to check if it's redirected to /dev/null or not. > > > > I've found a method which could work: > > > > irb $stderr.inspect > > "#" > > > > So I could parse the resulting string. However it doesn't seem a very > > "cool" approach. Is there any there any other more ellegant way? > > > > Thanks a lot. > > You can use $stderr.tty? if you just need to know if a terminal is > listening. Great! It also works in case $stderr is redirected to a file in which case $stderr.tty? also returns false :) Thanks. -- Iñaki Baz Castillo