X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/6c86b28db134c57a8c04cf3245e55fc09e663553..bdd68a4503870aee97f7d03bb7023726daf71a3f:/sbin/ping/ping.c diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 9ba6c6af5c..3609ae2fe6 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