*/
char hostname_g[DATA_MAX_NAME_LEN];
cdtime_t interval_g;
-int pidfile_from_cli = 0;
int timeout_g;
#if HAVE_LIBKSTAT
kstat_ctl_t *kc;
while ((dirlen > 0) && (dir[dirlen - 1] == '/'))
dir[--dirlen] = '\0';
- if (dirlen <= 0) {
+ if (dirlen == 0) {
free (dir);
return (-1);
}
/* TODO
* Remove all settings but `-f' and `-C'
*/
+__attribute__((noreturn))
static void exit_usage (int status)
{
printf ("Usage: "PACKAGE_NAME" [OPTIONS]\n\n"
}
#endif
- plugin_init_all ();
-
- return (0);
+ return plugin_init_all ();
} /* int do_init () */
static int do_shutdown (void)
{
- plugin_shutdown_all ();
- return (0);
+ return plugin_shutdown_all ();
} /* int do_shutdown */
#if COLLECT_DAEMON
struct sigaction sig_term_action;
struct sigaction sig_usr1_action;
struct sigaction sig_pipe_action;
- char *configfile = CONFIGFILE;
+ const char *configfile = CONFIGFILE;
int test_config = 0;
int test_readall = 0;
const char *basedir;
break;
case 'T':
test_readall = 1;
- global_option_set ("ReadThreads", "-1");
+ global_option_set ("ReadThreads", "-1", 1);
#if COLLECT_DAEMON
daemonize = 0;
#endif /* COLLECT_DAEMON */
break;
#if COLLECT_DAEMON
case 'P':
- global_option_set ("PIDFile", optarg);
- pidfile_from_cli = 1;
+ global_option_set ("PIDFile", optarg, 1);
break;
case 'f':
daemonize = 0;
/*
* run the actual loops
*/
- do_init ();
+ if (do_init () != 0)
+ {
+ ERROR ("Error: one or more plugin init callbacks failed.");
+ exit_status = 1;
+ }
if (test_readall)
{
if (plugin_read_all_once () != 0)
+ {
+ ERROR ("Error: one or more plugin read callbacks failed.");
exit_status = 1;
+ }
}
else
{
/* close syslog */
INFO ("Exiting normally.");
- do_shutdown ();
+ if (do_shutdown () != 0)
+ {
+ ERROR ("Error: one or more plugin shutdown callbacks failed.");
+ exit_status = 1;
+ }
#if COLLECT_DAEMON
if (daemonize)