]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
when looping on a list of service names with --csv, do not exit on the first
authorVaibhav Bajpai <contact@vaibhavbajpai.com>
Sun, 5 May 2013 16:35:53 +0000 (18:35 +0200)
committerR.E. Wolff <R.E.Wolff@BitWizard.nl>
Mon, 13 May 2013 15:22:54 +0000 (17:22 +0200)
failure; instead write the error on stderr, skip that service names and move
on to the next service name in the list

mtr.c

diff --git a/mtr.c b/mtr.c
index 58671fb4b8715f63da20e0410eeca93593d977b8..7675265523230e8bd31639823e836293946050be 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -532,7 +532,11 @@ int main(int argc, char **argv)
 
     if (net_preopen_result != 0) {
       fprintf(stderr, "mtr: Unable to get raw socket.  (Executable not suid?)\n");
-      exit(1);
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
     }
 
 #ifdef ENABLE_IPV6
@@ -546,7 +550,12 @@ int main(int argc, char **argv)
          perror ("Failed to resolve host");
       else
          fprintf (stderr, "Failed to resolve host: %s\n", gai_strerror(error));
-      exit( EXIT_FAILURE );
+
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
     }
     /* Convert the first addrinfo into a hostent. */
     host = &trhost;
@@ -568,26 +577,42 @@ int main(int argc, char **argv)
       break;
     default:
       fprintf( stderr, "mtr unknown address type\n" );
-      exit( EXIT_FAILURE );
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
     }
     alptr[1] = NULL;
 #else
       host = gethostbyname(Hostname);
     if (host == NULL) {
       herror("mtr gethostbyname");
-      exit(1);
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
     }
     af = host->h_addrtype;
 #endif
 
     if (net_open(host) != 0) {
-    fprintf(stderr, "mtr: Unable to start net module.\n");
-          exit(1);
-        }
+      fprintf(stderr, "mtr: Unable to start net module.\n");
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
+    }
 
     if (net_set_interfaceaddress (InterfaceAddress) != 0) {
       fprintf( stderr, "mtr: Couldn't set interface address.\n" );
-      exit( EXIT_FAILURE );
+      if ( DisplayMode != DisplayCSV ) exit(EXIT_FAILURE);
+      else {
+        names = names->next;
+        continue;
+      }
     }
 
     display_open();