aboutsummaryrefslogtreecommitdiffstats
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-22 14:55:45 -0800
committerJunio C Hamano <gitster@pobox.com>2023-02-22 14:55:45 -0800
commit5048df67b295baeaaa6dafb16ff712bd2a62731a (patch)
tree3c1325ae2d6ddb123323fc30452dd56043e66c51 /run-command.c
parentMerge branch 'ab/various-leak-fixes' (diff)
parenthook: support a --to-stdin=<path> option (diff)
downloadgit-5048df67b295baeaaa6dafb16ff712bd2a62731a.tar.gz
git-5048df67b295baeaaa6dafb16ff712bd2a62731a.zip
Merge branch 'ab/hook-api-with-stdin'
Extend the run-hooks API to allow feeding data from the standard input when running the hook script(s). * ab/hook-api-with-stdin: hook: support a --to-stdin=<path> option sequencer: use the new hook API for the simpler "post-rewrite" call hook API: support passing stdin to hooks, convert am's 'post-rewrite' run-command: allow stdin for run_processes_parallel run-command.c: remove dead assignment in while-loop
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/run-command.c b/run-command.c
index 50cc011654..6bd16acb06 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1586,6 +1586,14 @@ static int pp_start_one(struct parallel_processes *pp,
if (i == opts->processes)
BUG("bookkeeping is hard");
+ /*
+ * By default, do not inherit stdin from the parent process - otherwise,
+ * all children would share stdin! Users may overwrite this to provide
+ * something to the child's stdin by having their 'get_next_task'
+ * callback assign 0 to .no_stdin and an appropriate integer to .in.
+ */
+ pp->children[i].process.no_stdin = 1;
+
code = opts->get_next_task(&pp->children[i].process,
opts->ungroup ? NULL : &pp->children[i].err,
opts->data,
@@ -1601,7 +1609,6 @@ static int pp_start_one(struct parallel_processes *pp,
pp->children[i].process.err = -1;
pp->children[i].process.stdout_to_stderr = 1;
}
- pp->children[i].process.no_stdin = 1;
if (start_command(&pp->children[i].process)) {
if (opts->start_failure)
@@ -1632,9 +1639,7 @@ static void pp_buffer_stderr(struct parallel_processes *pp,
const struct run_process_parallel_opts *opts,
int output_timeout)
{
- int i;
-
- while ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {
+ while (poll(pp->pfd, opts->processes, output_timeout) < 0) {
if (errno == EINTR)
continue;
pp_cleanup(pp, opts);