Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ping puzzle

John Chambers <jc at> writes:

> Here's a bizarre puzzle that I've been trying  to  solve  on  several
> linux boxen:  How does a parent process read the stderr of /bin/ping?
> It oughta be trivial.  But consider this ping of a  machine  that  is
> down at the moment:
> $ /bin/ping -n -i 10
> PING ( from : 56 data bytes
> From Destination Host Unreachable
> From Destination Host Unreachable
> ...
> Those error messages come out on stderr.  Running under bash, I tried
> piping it to a few commands:

> Ahy ideas?  Can someone make them work?

I'm fairly certain that those "From Destination Host
Unreachable" messages aren't going to stderr.  To prove this to
myself, I typed:

  ping -n -i 1 somemachine >stdout 2>stderr

and after a while, I killed this.  

The stderr file was empty, and the stdout file had all of my expected

(I'm sure you see where I'm going at this point...)

So, what is going on here is that ping's stdio layer is detecting that
its stdout isn't being directed at a tty, so it is configuring its
output to be fully buffered, and not line-buffered.  Since you're
specifying an interval of 10 seconds, it takes quite a while for
ping's stdio layer to flush...

Hope this helps,

Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)!kclark (GnuPG ID: B280F24E)!kdc

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /