summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da49de5)
raw | patch | inline | side by side (parent: da49de5)
author | Florian Forster <ff@octo.it> | |
Wed, 7 Sep 2011 01:08:32 +0000 (21:08 -0400) | ||
committer | Florian Forster <ff@octo.it> | |
Wed, 7 Sep 2011 01:08:32 +0000 (21:08 -0400) |
As far as I know, EXIT_FAILURE is only portable when used as-is, i.e. without
adding anything to it. Especially with "EXIT_FAILURE == -1" we might run into
trouble. I think it's more convenient to just use the number of failed hosts
rather than 1+<num> (on Linux).
adding anything to it. Especially with "EXIT_FAILURE == -1" we might run into
trouble. I think it's more convenient to just use the number of failed hosts
rather than 1+<num> (on Linux).
src/mans/oping.pod | patch | blob | history | |
src/oping.c | patch | blob | history |
diff --git a/src/mans/oping.pod b/src/mans/oping.pod
index f0af718dc92bd47adc672bd1a5e38d411ae22b7f..8b8c644cfad164b9f4b7001ec099ed4e05e6bd9a 100644 (file)
--- a/src/mans/oping.pod
+++ b/src/mans/oping.pod
zero means that the exit status will only be zero if I<all> replies for I<all>
hosts have been received.
+The exit status will indicate the number of hosts with more than I<percent>
+packets lost, up to a number of 255 failing hosts.
+
=back
=head1 COLORS
diff --git a/src/oping.c b/src/oping.c
index 37f5fa91bc27c3e658ce06fd6b399c9f58ea9f8e..762a3ea9f1eb65b732dd32235edf6a1551c005fe 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
#endif
} /* }}} void update_host_hook */
-/* Returns the number of hosts which failed to return more than the
- fraction opt_exit_status_threshold of pings */
+/* Prints statistics for each host, cleans up the contexts and returns the
+ * number of hosts which failed to return more than the fraction
+ * opt_exit_status_threshold of pings. */
static int post_loop_hook (pingobj_t *ping) /* {{{ */
{
pingobj_iter_t *iter;
opt_count--;
} /* while (opt_count != 0) */
+ /* Returns the number of failed hosts according to -Z. */
status = post_loop_hook (ping);
ping_destroy (ping);
- if (status)
- return (EXIT_FAILURE + status);
+ if (status == 0)
+ exit (EXIT_SUCCESS);
else
- return (EXIT_SUCCESS);
+ {
+ if (status > 255)
+ status = 255;
+ exit (status);
+ }
} /* }}} int main */
/* vim: set fdm=marker : */