diff options
-rw-r--r-- | ebtables.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -26,6 +26,7 @@ #include <stdio.h> #include <stdlib.h> #include <inttypes.h> +#include <signal.h> #include "include/ebtables_u.h" #include "include/ethernetdb.h" @@ -91,6 +92,7 @@ static struct option ebt_original_options[] = { "atomic-file" , required_argument, 0, 9 }, { "atomic-save" , no_argument , 0, 10 }, { "init-table" , no_argument , 0, 11 }, + { "concurrent" , no_argument , 0, 13 }, { 0 } }; @@ -374,6 +376,7 @@ static void print_help() "--set-counters -c chain\n" " pcnt bcnt : set the counters of the to be added rule\n" "--modprobe -M program : try to insert modules using this program\n" +"--concurrent : use a file lock to support concurrent scripts\n" "--version -V : print package version\n\n" "Environment variable:\n" ATOMIC_ENV_VARIABLE " : if set <FILE> (see above) will equal its value" @@ -525,6 +528,12 @@ void ebt_early_init_once() ebt_iterate_targets(merge_target); } +/* signal handler, installed when the option --concurrent is specified. */ +static void sighandler(int signum) +{ + exit(-1); +} + /* We use exec_style instead of #ifdef's because ebtables.so is a shared object. */ int do_command(int argc, char *argv[], int exec_style, struct ebt_u_replace *replace_) @@ -1037,6 +1046,11 @@ big_iface_length: replace->filename = (char *)malloc(strlen(optarg) + 1); strcpy(replace->filename, optarg); break; + case 13 : /* concurrent */ + signal(SIGINT, sighandler); + signal(SIGTERM, sighandler); + use_lockfd = 1; + break; case 1 : if (!strcmp(optarg, "!")) ebt_check_inverse2(optarg); |