From cbbd9e85fea934d7599e5027b6883a062338077e Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Mon, 7 Oct 2019 04:23:59 -0700 Subject: [PATCH] Updated main() with a few comments to illustrate high level flow. --- icmpmonitor.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/icmpmonitor.c b/icmpmonitor.c index f7e4a47..5dd5064 100644 --- a/icmpmonitor.c +++ b/icmpmonitor.c @@ -432,6 +432,7 @@ parse_params(int argc, char ** argv) } if (first_host_in_list == NULL) { fprintf(stderr, "ERROR: Unable to parse a config file.\n"); + print_usage(argv); exit(EXIT_FAILURE); } } @@ -439,14 +440,22 @@ parse_params(int argc, char ** argv) int main(int argc, char ** argv) { + /* Parse the command line options, load and parse the config file. */ parse_params(argc, argv); + /* Process config for each host, generating/verifying any necessary information. */ init_hosts(); + /* Make sure initialization left us with something useful. */ + assert(first_host_in_list); + + /* Pings are sent asynchronously. */ signal(SIGALRM, pinger); alarm(TIMER_RESOLUTION); + /* The main program loop listens for ping responses. */ get_response(); + /* Should be unreachable. */ exit(EXIT_SUCCESS); } -- 2.20.1