Bug 5025 - ping -c 1 deadmachine never returns
ping -c 1 deadmachine never returns
Product: Red Hat Linux
Classification: Retired
Component: netkit-base (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
Depends On:
  Show dependency treegraph
Reported: 1999-09-09 13:19 EDT by degraaf
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-09-09 16:14:16 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description degraaf 1999-09-09 13:19:20 EDT
I think there's a bug in ping - netkit-base-0.10-31; RedHat

When I send a single ping to a machine that's shut down,
ping keeps on trying after the first failure,
despite using -c 1 .
That means it's impossible to test whether a machine is
alive, eg
    ping -c 1 datix
    if [ $? -eq 0 ]; then
        echo "It's alive"
        echo "No ping response"

because ping *never* returns!
Ping reports "Destination Host Unreachable" over and over...

    ping -c 1 somemachine
works as expected if "somemachine" responds (returns 0)
or "somemachine" doesn't exist (returns 1)
but if "somemachine" exists but is turned off, ping tries

Ping(1) clearly states:
  If ping does not receive any reply packets at all it will
exit with code
  1.  On error it exits with code 2. Otherwise it exits with
code 0. This
  makes it possible to use the exit code to see if a host is
alive or not.

I've written a little script to work around this bug, but
I'm not happy having to do so.  Can ping be fixed to agree
with its man page?

**************   /usr/local/bin/pingtest   *************

#   Silently pings $1 to see if it's alive,
#   with protection against hangs if it's not (ping has a
#   Returns 0 if alive; else 1

nohup ping -c1 $1 > /dev/null 2>&1 &
sleep 2
PINGPID=` ps | grep "ping " | grep -v grep | cut -d " " -f1
if [ -n "$PINGPID" ]; then
#    echo "ping $1 is hung; kill $PINGPID"
    kill $PINGPID
    exit 1
#    echo ping $1 succeeded
    exit 0

**************   END /usr/local/bin/pingtest   *************

This must be a bug.
Comment 1 David Lawrence 1999-09-09 16:14:59 EDT
This problem should be fixed in the latest rawhide version of
netkit-base available at:


Please try this one and reopen this bug if the problem continues. This
fix will also be in the next release.

------- Additional Comments From   09/30/99 17:23 -------
This bug appears to have resurfaced in netkit-base-0.10-37.
Comment 2 rhardy 1999-12-11 04:44:59 EST
Other recent problems with ping were solved by redhat replacing the ping they
were using with the one from iputils-990610. This ping has a -w option which
is broken which could have been used to circumvent the timeout problem.
If you take the ping from iputils-991024 this now works properly.
i.e. w/ 991024 "ping -w 10 -c 1 deadhost" will return for both a host on the
local network and hosts on remote networks. I was going to upload an rpm to
contrib.redhat.com but apparently I'm not allowed. Is there a special
site/directory for uploads?

Note You need to log in before you can comment on or make changes to this bug.