From: Vaibhav Bajpai Date: Sun, 5 May 2013 16:35:53 +0000 (+0200) Subject: when looping on a list of service names with --csv, do not exit on the first X-Git-Tag: v0.85~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9807ccd617b659b8b2abd84351e478d1a5eb71cb;p=thirdparty%2Fmtr.git when looping on a list of service names with --csv, do not exit on the first failure; instead write the error on stderr, skip that service names and move on to the next service name in the list --- diff --git a/mtr.c b/mtr.c index 58671fb..7675265 100644 --- 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();