summaryrefslogtreecommitdiffstats
path: root/sbin/ping6/ping6.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2008-05-27 10:51:19 +0000
committerbz <bz@FreeBSD.org>2008-05-27 10:51:19 +0000
commit08921e6dda68b6e98a89e884f0903049ce3c6ba5 (patch)
tree991405f7236fac6a4105ad280ef8b6df560f69ff /sbin/ping6/ping6.c
parent87fbf5762c02a0e9d828b5b8cd889c16d7ea8942 (diff)
downloadFreeBSD-src-08921e6dda68b6e98a89e884f0903049ce3c6ba5.zip
FreeBSD-src-08921e6dda68b6e98a89e884f0903049ce3c6ba5.tar.gz
Change the exit status for 0 and 2 to be the same as with ping(1)
and be usable in scripts, etc. This also changes the semantics in case when we lose one of n packets. In that case, before we exited by SIG, now we exit with return(0). Submitted by: Gert Doering (gert space.net) MFC after: 10 days
Diffstat (limited to 'sbin/ping6/ping6.c')
-rw-r--r--sbin/ping6/ping6.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index ee0847e..849c17a 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1074,6 +1074,9 @@ main(argc, argv)
/* signal handling */
if (seenalrm) {
+ /* last packet sent, timeout reached? */
+ if (npackets && ntransmitted >= npackets)
+ break;
retransmit();
seenalrm = 0;
continue;
@@ -1173,7 +1176,7 @@ main(argc, argv)
break;
}
summary();
- exit(nreceived == 0);
+ exit(nreceived == 0 ? 2 : 0);
}
void
@@ -1224,7 +1227,7 @@ retransmit()
itimer.it_interval.tv_usec = 0;
itimer.it_value.tv_usec = 0;
- (void)signal(SIGALRM, onint);
+ (void)signal(SIGALRM, onsignal);
(void)setitimer(ITIMER_REAL, &itimer, NULL);
}
OpenPOWER on IntegriCloud