projects
/
icmpmonitor
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tracking return value of system().
[icmpmonitor]
/
icmpmonitor.c
diff --git
a/icmpmonitor.c
b/icmpmonitor.c
index
f7e4a47
..
76404c2
100644
(file)
--- a/
icmpmonitor.c
+++ b/
icmpmonitor.c
@@
-133,8
+133,8
@@
pinger(int ignore) /* Dummy parameter since this function registers as a signal
if (verbose) printf("INFO: Host %s stopped responding. Executing DOWN command.\n", host->name);
host->host_up = false;
if (!fork()) {
if (verbose) printf("INFO: Host %s stopped responding. Executing DOWN command.\n", host->name);
host->host_up = false;
if (!fork()) {
- system(host->down_cmd);
- exit(
EXIT_SUCCESS
);
+
int sys_ret =
system(host->down_cmd);
+ exit(
sys_ret
);
}
}
}
}
@@
-201,8
+201,8
@@
read_icmp_data(struct host_entry * host)
if (verbose) printf("INFO: Host %s started responding. Executing UP command.\n", host->name);
host->host_up = true;
if (!fork()) {
if (verbose) printf("INFO: Host %s started responding. Executing UP command.\n", host->name);
host->host_up = true;
if (!fork()) {
- system(host->up_cmd);
- exit(
EXIT_SUCCESS
);
+
int sys_ret =
system(host->up_cmd);
+ exit(
sys_ret
);
}
}
} else {
}
}
} else {
@@
-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");
}
if (first_host_in_list == NULL) {
fprintf(stderr, "ERROR: Unable to parse a config file.\n");
+ print_usage(argv);
exit(EXIT_FAILURE);
}
}
exit(EXIT_FAILURE);
}
}
@@
-439,14
+440,22
@@
parse_params(int argc, char ** argv)
int
main(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);
parse_params(argc, argv);
+ /* Process config for each host, generating/verifying any necessary information. */
init_hosts();
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);
signal(SIGALRM, pinger);
alarm(TIMER_RESOLUTION);
+ /* The main program loop listens for ping responses. */
get_response();
get_response();
+ /* Should be unreachable. */
exit(EXIT_SUCCESS);
}
exit(EXIT_SUCCESS);
}