diff options
| author | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 | 
|---|---|---|
| committer | svn2git <svn2git@FreeBSD.org> | 1994-05-01 08:00:00 +0000 | 
| commit | a16f65c7d117419bd266c28a1901ef129a337569 (patch) | |
| tree | 2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /sbin/ping/ping.c | |
| parent | 8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff) | |
Diffstat (limited to 'sbin/ping/ping.c')
| -rw-r--r-- | sbin/ping/ping.c | 19 | 
1 files changed, 18 insertions, 1 deletions
| diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 9ba6c6af5c27..3609ae2fe621 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -709,7 +709,24 @@ finish()  	if (nreceived && timing)  		(void)printf("round-trip min/avg/max = %.3f/%.3f/%.3f ms\n",  		    tmin/1000.0, tsum/(nreceived + nrepeats)/1000.0, tmax/1000.0); -	exit(0); + +	/* +	 * 13NOV93 GRS +	 * added code to return 1 if no packets were returned to the receiver. +	 * Originally PING returned 0 regardless of how many packets were  +	 * returned, thus the only way to test the return value of PING in a  +	 * shell script was to do something like: +	 * +	 *   if ping -n -c 1 -r $IP_ADDR | grep '0 packets received' >/dev/null +	 * +	 * now, all that is needed is: +	 * +	 *   if ping -n -c 1 -r $IP_ADDR >/dev/null +	 */ +	if (nreceived) +		exit (0); +	else +		exit (1);  }  #ifdef notdef | 
