If no hosts could be added (e.g. because resolving the hostnames failed) the
oping application didn't exit but seemed to hang. Actually it was calling
`poll' (or select?) without any file descriptors, and not outputting anything
at all.
This patch makes oping exit if no hosts could be added to the oping library.
for (i = optind; i < argc; i++)
{
for (i = optind; i < argc; i++)
{
- if (ping_host_add (ping, argv[i]) > 0)
+ if (ping_host_add (ping, argv[i]) < 0)
{
fprintf (stderr, "ping_host_add (%s) failed\n", argv[i]);
continue;
}
}
{
fprintf (stderr, "ping_host_add (%s) failed\n", argv[i]);
continue;
}
}
for (iter = ping_iterator_get (ping);
iter != NULL;
iter = ping_iterator_next (iter))
for (iter = ping_iterator_get (ping);
iter != NULL;
iter = ping_iterator_next (iter))
context->host, context->addr, (unsigned int) buffer_size);
ping_iterator_set_context (iter, (void *) context);
context->host, context->addr, (unsigned int) buffer_size);
ping_iterator_set_context (iter, (void *) context);
+
+ i++;
+ }
+
+ if (i == 0)
+ {
+ fprintf (stderr, "No valid hosts left.\n");
+ exit (1);
}
memset (&sigint_action, '\0', sizeof (sigint_action));
}
memset (&sigint_action, '\0', sizeof (sigint_action));