Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Adrian Ratiu <adrian.ratiu@collabora.com>,
	 rsbecker@nexbridge.com, git@vger.kernel.org
Subject: Re: [PATCH] run_processes_parallel(): fix order of sigpipe handling
Date: Wed, 08 Apr 2026 10:59:37 -0700	[thread overview]
Message-ID: <xmqqcy09z62e.fsf@gitster.g> (raw)
In-Reply-To: <20260408172055.GA2293804@coredump.intra.peff.net> (Jeff King's message of "Wed, 8 Apr 2026 13:20:55 -0400")

Jeff King <peff@peff.net> writes:

> We can fix it by reordering the code a bit. We should run pp_init()
> first, and then push our SIG_IGN onto the stack afterwards, so that it
> is truly ignored while feeding the sub-processes.
>
> Note that we also reorder the popping at the end of the function, too.
> This is not technically necessary, as we are doing two pops either way,
> but now the pops will correctly match their pushes.

Sounds quite sensible.

> This also fixes a related case that we can't test yet. If we did have
> more than one process to run, then one child causing SIGPIPE would cause
> us to kill() all of the children (which might still actually be
> running). But the hook API is the only user of the new feed_pipe
> feature, and it does not yet support parallel hook execution. So for now
> we'll always execute the processes sequentially. Once parallel hook
> execution exists, we'll be able to add a test which covers this.

Great.

> Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
> Signed-off-by: Jeff King <peff@peff.net>

Thanks, all of you, for addressing the issue so quickly.

Applied.

> ---
>  run-command.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/run-command.c b/run-command.c
> index 32c290ee6a..574d5c40f0 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1895,14 +1895,19 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
>  					   "max:%"PRIuMAX,
>  					   (uintmax_t)opts->processes);
>  
> +	pp_init(&pp, opts, &pp_sig);
> +
>  	/*
>  	 * Child tasks might receive input via stdin, terminating early (or not), so
>  	 * ignore the default SIGPIPE which gets handled by each feed_pipe_fn which
>  	 * actually writes the data to children stdin fds.
> +	 *
> +	 * This _must_ come after pp_init(), because it installs its own
> +	 * SIGPIPE handler (to cleanup children), and we want to supersede
> +	 * that.
>  	 */
>  	sigchain_push(SIGPIPE, SIG_IGN);
>  
> -	pp_init(&pp, opts, &pp_sig);
>  	while (1) {
>  		for (i = 0;
>  		    i < spawn_cap && !pp.shutdown &&
> @@ -1928,10 +1933,10 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
>  		}
>  	}
>  
> -	pp_cleanup(&pp, opts);
> -
>  	sigchain_pop(SIGPIPE);
>  
> +	pp_cleanup(&pp, opts);
> +
>  	if (do_trace2)
>  		trace2_region_leave(tr2_category, tr2_label, NULL);
>  }

  reply	other threads:[~2026-04-08 17:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 23:37 Help needed on 2.54.0-rc0 t5301.13 looping rsbecker
2026-04-08  5:20 ` Jeff King
2026-04-08  5:43   ` Jeff King
2026-04-08 11:53     ` Adrian Ratiu
2026-04-08 15:44       ` rsbecker
2026-04-08 15:52       ` rsbecker
2026-04-08 15:55       ` rsbecker
2026-04-08 16:53       ` Junio C Hamano
2026-04-08 16:58         ` rsbecker
2026-04-08 17:01         ` Adrian Ratiu
2026-04-08 17:30           ` [PATCH] t5401: test SIGPIPE with parallel hooks Jeff King
2026-04-08 15:50   ` Help needed on 2.54.0-rc0 t5301.13 looping Junio C Hamano
2026-04-08 16:26     ` Adrian Ratiu
2026-04-08 17:20       ` [PATCH] run_processes_parallel(): fix order of sigpipe handling Jeff King
2026-04-08 17:59         ` Junio C Hamano [this message]
2026-04-08 20:54           ` Junio C Hamano
2026-04-08 23:42             ` Jeff King
2026-04-09 13:40               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqcy09z62e.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=adrian.ratiu@collabora.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=rsbecker@nexbridge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox