Fix exit status when -c and -X is used

It exited with status 0 when at least one packet was received
and timed out. However, when we specify -c N (while N > 0),
we expect that it fails if it times out before all sent requests
are replied.
This commit is contained in:
ozaki-r 2015-11-04 07:59:25 +00:00
parent 6294105d33
commit c94323a777
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ping6.c,v 1.89 2015/11/04 01:14:02 knakahara Exp $ */
/* $NetBSD: ping6.c,v 1.90 2015/11/04 07:59:25 ozaki-r Exp $ */
/* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
/*
@ -77,7 +77,7 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ping6.c,v 1.89 2015/11/04 01:14:02 knakahara Exp $");
__RCSID("$NetBSD: ping6.c,v 1.90 2015/11/04 07:59:25 ozaki-r Exp $");
#endif
#endif
@ -1146,7 +1146,10 @@ main(int argc, char *argv[])
break;
}
summary();
exit(nreceived == 0);
if (npackets)
exit(nreceived != npackets);
else
exit(nreceived == 0);
}
static void