From avleen@guava.silverwraith.com  Mon Dec 23 09:09:54 2002
Return-Path: <avleen@guava.silverwraith.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CBA2937B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Dec 2002 09:09:54 -0800 (PST)
Received: from guava.silverwraith.com (66-214-248-56.gln-eres.charterpipeline.net [66.214.248.56])
	by mx1.FreeBSD.org (Postfix) with SMTP id D9BA543EDE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Dec 2002 09:09:48 -0800 (PST)
	(envelope-from avleen@guava.silverwraith.com)
Received: (qmail 46182 invoked by uid 0); 23 Dec 2002 17:09:37 -0000
Message-Id: <20021223170937.46181.qmail@guava.silverwraith.com>
Date: 23 Dec 2002 17:09:37 -0000
From: Avleen Vig <spam-pr@silverwraith.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Avleen Vig <spam-pr@silverwraith.com>
Subject: Ping exits 2 when it should exit 1
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46501
>Category:       bin
>Synopsis:       Ping exits 2 when it should exit 1
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 23 09:10:01 PST 2002
>Closed-Date:    Tue Dec 24 00:49:26 PST 2002
>Last-Modified:  Tue Dec 24 01:00:19 PST 2002
>Originator:     Avleen Vig
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
none
>Environment:
System: FreeBSD guava.silverwraith.com 4.7-STABLE FreeBSD 4.7-STABLE #0: Sat Dec 21 16:30:53 PST 2002 root@guava.silverwraith.com:/usr/src/sys/compile/GUAVA i386


	FreeBSD 4.7-STABLE as of Nov28th.

>Description:
	The ping(8) manpage claims that if ping transmits packets but
	does not recieve a reply, it should exit one. However, it exits
	2. Exiting 1 makes more sense than exiting 2, so I submit this
	patch.

	The bad code was put into ping in revision 1.4 on Nov 29 1994.

>How-To-Repeat:
	ping -c1 -t1 1.2.3.4; echo $?

>Fix:

	Apply this patch to src/sbin/ping/ping.c :

--- ping.c.orig Mon Dec 23 08:51:56 2002
+++ ping.c      Mon Dec 23 08:55:49 2002
@@ -1161,7 +1161,7 @@
        if (nreceived)
                exit(0);
        else
-               exit(2);
+               exit(1);
 }
 
 #ifdef notdef
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: trhodes 
State-Changed-When: Mon Dec 23 22:39:34 PST 2002 
State-Changed-Why:  
Exit is already documented as 2, like the code. 
This has been 2 for a long time now, why do you want to change it 
all of a sudden?  In my opinion this change isn't correct because so 
many other utilities are using exit(2); also. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46501 
State-Changed-From-To: feedback->closed 
State-Changed-By: trhodes 
State-Changed-When: Tue Dec 24 00:48:42 PST 2002 
State-Changed-Why:  
Submitter agree's to this PR's closure.  Thanks for the submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46501 

From: Maxim Konovalov <maxim@FreeBSD.org>
To: Avleen Vig <spam-pr@silverwraith.com>
Cc: Tom Rhodes <trhodes@FreeBSD.org>, "" <bug-followup@FreeBSD.org>
Subject: Re: bin/46501: Ping exits 2 when it should exit 1
Date: Tue, 24 Dec 2002 11:41:01 +0300 (MSK)

 On 23:30-0800, Dec 23, 2002, Avleen Vig wrote:
 
 > > Exit is already documented as 2, like the code.
 > > This has been 2 for a long time now, why do you want to change it
 > > all of a sudden?  In my opinion this change isn't correct because so
 > > many other utilities are using exit(2); also.
 >
 > Ping is documented as I stated in ping(8) as exiting 1 when it actually
 > exits 2.
 
 From ping(8):
 
 RETURN VALUES
      The ping utility returns an exit status of zero if at least one response
      was heard from the specified host; a status of two if the transmission
 ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      was successful but no responses were received; or another value (from
      <sysexits.h>) if an error occurred.
 
 > I don't know of any other utils that exit(2) when they don't have somthing
 > exiting 1 already.
 > It makes little sense to exit(2) when there's nothing in ping that will
 > exit(1).
 >
 > Thus it makes sense to correct this. I don't believe "it haven't been
 > changed for a long time" is a valid reason for leaving something
 > broken/incorrect.
 >
 > If this won't be fixed, then the documentation needs to be fixed, but I
 > don't feel that's correct.
 
 -- 
 Maxim Konovalov, maxim@FreeBSD.org
 

From: Avleen Vig <spam-pr@silverwraith.com>
To: Maxim Konovalov <maxim@FreeBSD.org>
Cc: Tom Rhodes <trhodes@FreeBSD.org>, "" <bug-followup@FreeBSD.org>
Subject: Re: bin/46501: Ping exits 2 when it should exit 1
Date: Tue, 24 Dec 2002 00:45:05 -0800 (PST)

 On Tue, 24 Dec 2002, Maxim Konovalov wrote:
 
 > RETURN VALUES
 >      The ping utility returns an exit status of zero if at least one response
 >      was heard from the specified host; a status of two if the transmission
 > ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 >      was successful but no responses were received; or another value (from
 >      <sysexits.h>) if an error occurred.
 
 My sincerest apologies. I think I'm going completely mad.
 I don't know how I read that as 'exists one if the...'.
 
 It still seems to make little sense to have it exit(2) if nothing will
 cause it to exit(1).
 But I shan't argue this further. Thanks folks. Sorry for the hassle.

From: Tom Rhodes <trhodes@FreeBSD.org>
To: Maxim Konovalov <maxim@FreeBSD.org>
Cc: spam-pr@silverwraith.com, bug-followup@FreeBSD.org
Subject: Re: bin/46501: Ping exits 2 when it should exit 1
Date: Tue, 24 Dec 2002 03:47:25 -0500

 On Tue, 24 Dec 2002 11:41:01 +0300 (MSK)
 Maxim Konovalov <maxim@FreeBSD.org> wrote:
 
 > On 23:30-0800, Dec 23, 2002, Avleen Vig wrote:
 > 
 > > > Exit is already documented as 2, like the code.
 > > > This has been 2 for a long time now, why do you want to change it
 > > > all of a sudden?  In my opinion this change isn't correct because
 > > > so many other utilities are using exit(2); also.
 > >
 > > Ping is documented as I stated in ping(8) as exiting 1 when it
 > > actually exits 2.
 > 
 > From ping(8):
 > 
 > RETURN VALUES
 >      The ping utility returns an exit status of zero if at least one
 >      response was heard from the specified host; a status of two if
 >      the transmission
 > ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 > ^^^^^^
 >      was successful but no responses were received; or another value
 >      (from<sysexits.h>) if an error occurred.
 > 
 > > I don't know of any other utils that exit(2) when they don't have
 > > somthing exiting 1 already.
 
 src/sbin/fsck
 src/sbin/mountd
 src/sbin/routed
 src/sbin/tunefs
 src/bin/sh
 src/sbin/savecore
 src/usr.sbin/usbd
 src/usr.sbin/fdcontrol
 src/usr.sbin/lpd
 
 all use exit(2);  This seems common.
 
 > > It makes little sense to exit(2) when there's nothing in ping that
 > > will exit(1).
 > >
 > > Thus it makes sense to correct this. I don't believe "it haven't
 > > been changed for a long time" is a valid reason for leaving
 > > something broken/incorrect.
 > >
 > > If this won't be fixed, then the documentation needs to be fixed,
 > > but I don't feel that's correct.
 > 
 > -- 
 > Maxim Konovalov, maxim@FreeBSD.org
 > 
 > 

From: Tom Rhodes <trhodes@FreeBSD.org>
To: Avleen Vig <spam-pr@silverwraith.com>
Cc: maxim@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: bin/46501: Ping exits 2 when it should exit 1
Date: Tue, 24 Dec 2002 03:53:58 -0500

 On Tue, 24 Dec 2002 00:45:05 -0800 (PST)
 Avleen Vig <spam-pr@silverwraith.com> wrote:
 
 > On Tue, 24 Dec 2002, Maxim Konovalov wrote:
 > 
 > > RETURN VALUES
 > >      The ping utility returns an exit status of zero if at least one
 > >      response was heard from the specified host; a status of two if
 > >      the transmission
 > > ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^
 > > ^^^^^^^^
 > >      was successful but no responses were received; or another value
 > >      (from<sysexits.h>) if an error occurred.
 > 
 > My sincerest apologies. I think I'm going completely mad.
 > I don't know how I read that as 'exists one if the...'.
 > 
 > It still seems to make little sense to have it exit(2) if nothing will
 > cause it to exit(1).
 > But I shan't argue this further. Thanks folks. Sorry for the hassle.
 > 
 
 In all honesty we are not trying to drive you nuts.  While it may
 seem to be a logical change, it will break scripts, compatibility
 or worse.  We thank you for the effort though!
 
 --
 Tom Rhodes
>Unformatted:
