diff options
author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-05-27 10:51:19 +0000 |
---|---|---|
committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2008-05-27 10:51:19 +0000 |
commit | 115737b17382cf8867f4a59c516ebd2963bb3218 (patch) | |
tree | 991405f7236fac6a4105ad280ef8b6df560f69ff | |
parent | d92b4112c6c8fd1a2769775e4556b666d4630b72 (diff) |
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
Notes
Notes:
svn path=/head/; revision=179356
-rw-r--r-- | sbin/ping6/ping6.8 | 6 | ||||
-rw-r--r-- | sbin/ping6/ping6.c | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8 index fc59591c9ce0..fe57b992b882 100644 --- a/sbin/ping6/ping6.8 +++ b/sbin/ping6/ping6.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 15, 2007 +.Dd May 27, 2008 .Dt PING6 8 .Os .Sh NAME @@ -409,7 +409,9 @@ option of The .Nm utility returns 0 on success (the host is alive), -and non-zero if the arguments are incorrect or the host is not responding. +2 if the transmission was successful but no responses were received, +any other non-zero value if the arguments are incorrect or +another error has occured. .Sh EXAMPLES Normally, .Nm diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index ee0847ed4344..849c17a0e90c 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); } |