>From 317c936677d7b06f6972d5214b8c38aab1e26121 Mon Sep 17 00:00:00 2001 From: Ed Neville Date: Tue, 21 Sep 2010 20:59:19 +0100 Subject: [PATCH] This change adds a sleep between invocations of cmd. --- xargs/xargs.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xargs/xargs.c b/xargs/xargs.c index 22668d3..b9ff31b 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -175,6 +175,9 @@ static bool query_before_executing = false; */ static char input_delimiter = '\0'; +/* Delay between invocations of cmd and flag for previous delay */ +static int delay_before_executing = 0; +static int delay_before_executing_cycle = 0; static struct option const longopts[] = { @@ -185,6 +188,7 @@ static struct option const longopts[] = {"replace", optional_argument, NULL, 'I'}, {"max-lines", optional_argument, NULL, 'l'}, {"max-args", required_argument, NULL, 'n'}, + {"delay", required_argument, NULL, 'D'}, {"interactive", no_argument, NULL, 'p'}, {"no-run-if-empty", no_argument, NULL, 'r'}, {"max-chars", required_argument, NULL, 's'}, @@ -478,7 +482,7 @@ main (int argc, char **argv) bc_use_sensible_arg_max (&bc_ctl); } - while ((optc = getopt_long (argc, argv, "+0a:E:e::i::I:l::L:n:prs:txP:d:", + while ((optc = getopt_long (argc, argv, "+0a:E:e::i::I:l::L:n:prs:txP:d:D:", longopts, (int *) 0)) != -1) { switch (optc) @@ -492,6 +496,10 @@ main (int argc, char **argv) read_args = read_string; input_delimiter = get_input_delimiter (optarg); break; + + case 'D': + delay_before_executing = parse_num (optarg, 'D', 1L, -1L, 1); + break; case 'E': /* POSIX */ case 'e': /* deprecated */ @@ -1087,6 +1095,17 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char * (void) ctl; + if (delay_before_executing != 0 && delay_before_executing_cycle > 0 ) + sleep (delay_before_executing ); + else + { + if (delay_before_executing != 0 ) + { + delay_before_executing_cycle = 1; + } + } + + if (!query_before_executing || print_args (true)) { if (proc_max) @@ -1509,7 +1528,7 @@ Usage: %s [-0prtx] [--interactive] [--null] [-d|--delimiter=delim]\n\ [-E eof-str] [-e[eof-str]] [--eof[=eof-str]]\n\ [-L max-lines] [-l[max-lines]] [--max-lines[=max-lines]]\n\ [-I replace-str] [-i[replace-str]] [--replace[=replace-str]]\n\ - [-n max-args] [--max-args=max-args]\n\ + [-n max-args] [--max-args=max-args] [-D|--delay=[iteration delay sec]]\n\ [-s max-chars] [--max-chars=max-chars]\n\ [-P max-procs] [--max-procs=max-procs] [--show-limits]\n\ [--verbose] [--exit] [--no-run-if-empty] [--arg-file=file]\n\ -- 1.7.0.4