diff options
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index c531070..d3824a9 100644 --- a/src/options.c +++ b/src/options.c @@ -158,6 +158,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) argc--; + char* children_policy = NULL; int i; for(i=1; argc > 0; ++i) { @@ -176,6 +177,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_PARAM("-s","--command-sock", opt->command_sock_) PARSE_STRING_PARAM("-x","--script", opt->script_) PARSE_INT_PARAM("-m","--max-children", opt->max_children_) + PARSE_STRING_PARAM("-p","--children-policy", children_policy) PARSE_STRING_LIST("-d","--dir", opt->dirs_) else return i; @@ -186,6 +188,20 @@ int options_parse(options_t* opt, int argc, char* argv[]) opt->daemonize_ = 0; } + if(children_policy) { + if(!strcmp(children_policy, "defer")) + opt->children_policy_ = DEFER; + else if(!strcmp(children_policy, "drop")) + opt->children_policy_ = DROP; + else if(!strcmp(children_policy, "kill-oldest")) + opt->children_policy_ = KILL_OLDEST; + else + return -3; + } + + if(!opt->log_targets_.first_) + string_list_add(&opt->log_targets_, "syslog:3,dropnroll,daemon"); + if(!opt->dirs_.first_ && !opt->command_sock_) opt->command_sock_ = strdup("/var/run/dropnroll/cmd.sock"); @@ -226,6 +242,7 @@ void options_default(options_t* opt) opt->command_sock_ = NULL; opt->script_ = strdup("newfile.sh"); opt->max_children_ = 8; + opt->children_policy_ = DEFER; string_list_init(&opt->dirs_); } @@ -269,6 +286,8 @@ void options_print_usage() printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/dropnroll/cmd.sock\n"); printf(" [-x|--script] <script> the command socket e.g. newfile.sh\n"); printf(" [-m|--max-children] <#of children> limit of children to be started e.g. 8\n"); + printf(" [-p|--children-policy] (defer,drop,kill-oldest)\n"); + printf(" what to do when children limit exceeds\n"); printf(" [-d|--dir] <path> add a path to the watch list, can be invoked several times\n"); } @@ -290,5 +309,11 @@ void options_print(options_t* opt) printf("command_sock: '%s'\n", opt->command_sock_); printf("script: '%s'\n", opt->script_); printf("max_children: %d\n", opt->max_children_); + printf("children_policy: "); + switch(opt->children_policy_) { + case DEFER: printf("defer execution\n"); break; + case DROP: printf("drop\n"); break; + case KILL_OLDEST: printf("kill oldest\n"); break; + } string_list_print(&opt->dirs_, " '", "'\n"); } |