Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
John Chambers <jc at trillian.mit.edu> 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 64.28.81.46 > PING 64.28.81.46 (64.28.81.46) from 207.172.135.95 : 56 data bytes > From 64.14.70.146: Destination Host Unreachable > From 64.14.70.146: 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 64.14.70.146: 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 output. (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 -- Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA) cetaceannetworks.com!kclark (GnuPG ID: B280F24E) alumni.unh.edu!kdc
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |