From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Phillip Wood via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Eric Wong <e@80x24.org>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH] start_command: reset disposition of all signals in child
Date: Mon, 11 Sep 2023 10:50:33 +0100 [thread overview]
Message-ID: <c64cd85f-f14c-46b7-a0d3-b8e0bfc60053@gmail.com> (raw)
In-Reply-To: <xmqq8r9gtviv.fsf@gitster.g>
On 08/09/2023 18:38, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
>> Oh I should have looked more carefully at the existing uses. It looks
>> like it is only my sequencer patch that does
>>
>> sigchain_push(SIGINT, SIG_IGN);
>> sigchain_push(SIGQUIT, SIG_IGN);
>> res = run_command(...);
>
> Hmph, does it mean this patch would become unnecessary, once you fix
> the above sequence to follow the pattern "to spawn and then ignore"?
Yes, sorry for the confusion. There are a couple of things that I think
we should address though. Firstly we should change the comment in
run-command which says execve() resets ignored signals to SIG_DFL to say
something like
Preserve the set of ignored signals so that running git via a
wrapper like nohup works as the user expects
The other thing is that we have some instances where we ignore SIGPIPE
before calling start_command() which means we're ignoring it in the
child process as well. For example in gpg-interface.c we have
sigchain_push(SIGPIPE, SIG_IGN);
ret = pipe_command(&gpg, sigc->payload, sigc->payload_len, &gpg_stdout, 0,
&gpg_stderr, 0);
sigchain_pop(SIGPIPE);
To fix that one we'd need to change pipe_command() to ignore SIGPIPE
after calling start_command() or add a flag to struct child_process to
do to that.
Another example is in upload-pack.c
/*
* If the next rev-list --stdin encounters an unknown commit,
* it terminates, which will cause SIGPIPE in the write loop
* below.
*/
sigchain_push(SIGPIPE, SIG_IGN);
if (start_command(cmd))
goto error;
rev-list does not check for errors when writing to stdout unless
GIT_FLUSH is set in the environment so if parent process exits early
rev-list will keep going until it thinks it has printed everything.
I think adding a flag to struct child_process to ignore SIGPIPE in the
parent is probably the best way to avoid problems like this.
Best Wishes
Phillip
next prev parent reply other threads:[~2023-09-11 21:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 10:05 [PATCH] start_command: reset disposition of all signals in child Phillip Wood via GitGitGadget
2023-09-08 15:42 ` Junio C Hamano
2023-09-08 15:53 ` Phillip Wood
2023-09-08 16:24 ` Junio C Hamano
2023-09-08 16:43 ` Phillip Wood
2023-09-08 17:38 ` Junio C Hamano
2023-09-11 9:50 ` Phillip Wood [this message]
2023-09-11 22:20 ` Junio C Hamano
2023-09-08 19:57 ` Eric Wong
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=c64cd85f-f14c-46b7-a0d3-b8e0bfc60053@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=e@80x24.org \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).