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: Fri, 8 Sep 2023 17:43:33 +0100 [thread overview]
Message-ID: <376d3ea0-a3eb-4b25-8bf2-ca40c4699e26@gmail.com> (raw)
In-Reply-To: <xmqqmsxwtyy3.fsf@gitster.g>
On 08/09/2023 17:24, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
>> On 08/09/2023 16:42, Junio C Hamano wrote:
>>> "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>>
>>>> [3] This is really a work-around for not moving the child into its own
>>>> process group and changing the foreground process group of the
>>>> controlling terminal.
>>> I am puzzled, as I somehow thought that "does the user conceive a
>>> subprocess as external and different-from-git entity, or is it
>>> merely an implementation detail? many use of subprocesses in our
>>> codebase, it is the latter." from Peff was a good argument against
>>> such isolation between spawning "git" and spawned subprocesses.
>>
>> It is and in those cases we do not ignore SIGINT and SIGQUIT in the
>> parent when we fork the subprocess. What I was trying to say is that
>> in the few cases where we do ignore SIGINT and SIGQUIT in the parent
>> when we fork a subprocess we're working round the child being in the
>> same process group at the parent.
>
> Hmph, but picking a few grep hits for 'sigchain_push.*SIG_IGN' at
> random, the typical pattern seem to be (this example was taken from
> builtin/receive-pack.c):
>
> code = start_command(&proc);
> if (code) {
> ...
> return code;
> }
> sigchain_push(SIGPIPE, SIG_IGN);
> while (1) {
> ...
> }
> close(proc.in);
> sigchain_pop(SIGPIPE);
> return finish_command(&proc);
>
> The way we spawn an editor in editor.c looks the same:
>
> p.use_shell = 1;
> p.trace2_child_class = "editor";
> if (start_command(&p) < 0) {
> strbuf_release(&realpath);
> return error("unable to start editor '%s'", editor);
> }
>
> sigchain_push(SIGINT, SIG_IGN);
> sigchain_push(SIGQUIT, SIG_IGN);
> ret = finish_command(&p);
>
> IOW, we do not ignore then spawn. We spawn and ignore only in the
> parent, so there shouldn't be any reason to worry about our child
> inheriting the "we the parent git process do not want to be killed
> by \C-c" settings, should there?
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(...);
In that case the existing behavior is a problem but maybe I should
change those call sites to use start_command() and finish_command()
instead if we decide that other patch is a good idea.
> I have a vague recollection that the "propagate what was already
> ignored to be ignored down to the child, too" was not about signals
> we ignored, but inherited from the end-user who started git with
> certain signals ignored, but it is so old a piece of code that the
> details of the rationale escapes me.
The comment
/* ignored signals get reset to SIG_DFL on execve */
in start_command() makes it look like the code assumes ignored signals
will be reset to SIG_DFL by execve() which is not what happens. Maybe
that comment is just wrong and there is a good reason for the current
behavior.
Best Wishes
Phillip
next prev parent reply other threads:[~2023-09-08 16:43 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 [this message]
2023-09-08 17:38 ` Junio C Hamano
2023-09-11 9:50 ` Phillip Wood
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=376d3ea0-a3eb-4b25-8bf2-ca40c4699e26@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).