Return failure if ping gets no response.
authorMatt Kraai <kraai@debian.org>
Wed, 20 Sep 2000 04:33:30 +0000 (04:33 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 20 Sep 2000 04:33:30 +0000 (04:33 -0000)
networking/ping.c
ping.c

index 5f44a6816f9085a8f90c485dea4eb5de7c5abd2c..f3ce6fb80b60f82db2b7b448a2d0b1419969fc90 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.23 2000/07/16 20:57:15 kraai Exp $
+ * $Id: ping.c,v 1.24 2000/09/20 04:33:30 kraai Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -279,6 +279,8 @@ static void unpack(char *, int, struct sockaddr_in *);
 
 static void pingstats(int junk)
 {
+       int status;
+
        signal(SIGINT, SIG_IGN);
 
        printf("\n--- %s ping statistics ---\n", hostname);
@@ -294,7 +296,11 @@ static void pingstats(int junk)
                           tmin / 10, tmin % 10,
                           (tsum / (nreceived + nrepeats)) / 10,
                           (tsum / (nreceived + nrepeats)) % 10, tmax / 10, tmax % 10);
-       exit(0);
+       if (nreceived != 0)
+               status = EXIT_SUCCESS;
+       else
+               status = EXIT_FAILURE;
+       exit(status);
 }
 
 static void sendping(int junk)
diff --git a/ping.c b/ping.c
index 5f44a6816f9085a8f90c485dea4eb5de7c5abd2c..f3ce6fb80b60f82db2b7b448a2d0b1419969fc90 100644 (file)
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.23 2000/07/16 20:57:15 kraai Exp $
+ * $Id: ping.c,v 1.24 2000/09/20 04:33:30 kraai Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -279,6 +279,8 @@ static void unpack(char *, int, struct sockaddr_in *);
 
 static void pingstats(int junk)
 {
+       int status;
+
        signal(SIGINT, SIG_IGN);
 
        printf("\n--- %s ping statistics ---\n", hostname);
@@ -294,7 +296,11 @@ static void pingstats(int junk)
                           tmin / 10, tmin % 10,
                           (tsum / (nreceived + nrepeats)) / 10,
                           (tsum / (nreceived + nrepeats)) % 10, tmax / 10, tmax % 10);
-       exit(0);
+       if (nreceived != 0)
+               status = EXIT_SUCCESS;
+       else
+               status = EXIT_FAILURE;
+       exit(status);
 }
 
 static void sendping(int junk)