Message ID | patch-2.5-81eef2f60a0-20230123T170551Z-avarab@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | hook API: support stdin, convert post-rewrite | expand |
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes: > + /* > + * 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; For this single process, by default .no_stdin is set before it is passed to start_command(), so the default behaviour does not change. This needs a new safety to ensure that processes that have .no_stdin turned off do not share the same value in their .in member, doesn't it? Hopefully that will be added in a later step in the series? Provided that such a safety will appear in the end result, this conversion does make sense to me. Let's read on. > if (start_command(&pp->children[i].process)) { > if (opts->start_failure)
diff --git a/run-command.c b/run-command.c index b439c7974ca..6bd16acb060 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)