Bug 68919 - 'ping' command changed, lost features
'ping' command changed, lost features
Product: Red Hat Linux
Classification: Retired
Component: iputils (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
Mike McLean
: 69282 77685 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2002-07-15 19:14 EDT by Joel Votaw
Modified: 2015-03-04 20:11 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-05-14 11:28:22 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 Joel Votaw 2002-07-15 19:14:32 EDT
Description of Problem:

Two things (maybe more) have changed about the 'ping' command that break some 
shell scripts.

1. It's exit code seems to be the same regardless of whether or not it could 
ping the desired host.

2. When using the '-cN' option, ping will not exit after N packets have been 
sent and timed out.  I've been using the -w option instead, but it's really not 
the same.

In general it seems like quite a few command-line options have changed since we 
upgraded from RedHat 7.1.

Version-Release number of selected component (if applicable): iputils-ss020124

How Reproducible: 100%

Steps to Reproduce:
1. if ping -w5 somehost > /dev/null 2>&1; then echo true; fi
2. In my experience the above will always print "true" regardless of whether or 
not somehost is alive.
3. This makes it harder to write shell scripts which ping a host to see if it's 
alive before performing some action.

Actual Results:

Expected Results:

Additional Information: Please contact me if you need more info.
Comment 1 Mike McLean 2002-07-22 14:38:48 EDT
*** Bug 69282 has been marked as a duplicate of this bug. ***
Comment 2 giulioo 2002-11-12 06:29:57 EST
ping -c1 -w1 nonexistent_host
to have ping check for an host being up or down without hanging and with correct
exit status.
Comment 3 giulioo 2002-11-12 06:31:20 EST
*** Bug 77685 has been marked as a duplicate of this bug. ***
Comment 4 Joel Votaw 2002-11-12 11:50:37 EST
        ping -c1 -w1 nonexistenthost

does in fact do the job.  (Funny, I thought I tested that before and it didn't 
work ... I must be hallucinating).

It would still be nice for 

        ping -w1 nonexistenthost

to return the correct exit value, too.  ("success" should be determined by any 
packets coming back from the host, regardless of if you force the number of 
packets sent to a specific value.)

As a nitpick, I suggest adding this example to the manpage -- there seem to be 
several other people that have run into this problem too.

Also, how does the -c option work if -w is not also specified?  Does it ever 
time out, or does it just take a very long time?  Perhaps there should be an 
addition to the manpage under the -c descripttion that says "in practise this 
takes ages to time out so you probably want to specify -w also".

Thank you very much for your help with this.  I don't mean to complain too 
much, just offer constructive feedback so Linux can be even better.
Comment 5 Need Real Name 2002-12-03 11:05:17 EST
If an ordinary user on our default RH8 install tries to ping a non existant 
address like ping returns:

From 217.37.xx.xxx icmp_seq=1 Destination Port Unreachable


Trouble is if I run that for one second I get:

--- ping statistics ---
0 packets transmitted, 0 received, +6415 errors

CPU Usage and Load continue to grow as resources permit. I gave up when my load 
average went through 3 having no desire to see what would break.

I worry about the potential here for a local Denial of Service attack by anyone 
with a user account on the server.

Comment 6 Phil Knirsch 2003-05-14 11:28:22 EDT
This has been fixed in the current release. ping -c 1 will timeout again.

Read ya, Phil

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