From: Phillip Wood <phillip.wood123@gmail.com>
To: Jeff King <peff@peff.net>, phillip.wood@dunelm.org.uk
Cc: Phillip Wood via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] rebase -i: ignore signals when forking subprocesses
Date: Thu, 14 Sep 2023 14:50:00 +0100 [thread overview]
Message-ID: <f7f29dc3-c5cb-4522-95db-1bf13bd1e416@gmail.com> (raw)
In-Reply-To: <20230914095601.GE2254894@coredump.intra.peff.net>
On 14/09/2023 10:56, Jeff King wrote:
> On Fri, Sep 08, 2023 at 10:59:06AM +0100, Phillip Wood wrote:
>
>> Do we want a whole new session? As I understand it to launch a foreground
>> job shells put the child in its own process group and then call tcsetpgrp()
>> to change the foreground process group of the controlling terminal to that
>> of the child. I agree that would be a better way of doing things on unix.
>
> One thing I am not clear on is the convention on who does the process
> group and controlling terminal setup. Should Git do it to say "I am
> handing off control of the terminal to the editor that I am spawning"?
> Or should the editor say "I am an editor which has a user interface that
> takes over the terminal; I will control it while I am running".
As I understand it the editor has a controlling terminal (assuming there
is a controlling terminal associated with the editor's session id), not
the other way round. If the editor is launched in the background then it
will receive SIGTTIN when it tries to read from it's controlling
terminal which stops the process unless the process installs a signal
handler.
> The latter makes much more sense to me, as Git cannot know how the
> editor plans to behave. But as I understand it, this kind of job control
> stuff is implemented by the calling shell, which does the tcsetpgrp()
> call.
Yes, my understanding is that the shell puts all the processes in a
pipeline in the same process group and calls tcsetpgrp() if it wants
that job to be run in the foreground.
> So I dunno. It sounds to me like the "right" thing here is making Git
> more shell-like in handing control to a program (like the editor) that
> we expect to be in the foreground of the terminal. As opposed to the
> "ignore SIGINT temporarily" thing which feels more like band-aid. But
> I'm wary of getting into a rabbit hole of portability headaches and
> weird corners of Unix terminal-handling conventions.
I'm wary of that too, it has the potential to end up adding a lot of
fiddly code checking if git is in the foreground or background and
propagating SIGTSTP and friends up to the shell. In any case we'd need
the "ignore SIGINT" thing for windows anyway. Ignoring SIGINT and
SIGQUIT in the parent is what system(3) does. As long as git exits
promptly when the interrupted child is killed I think that is
reasonable. Would you be happier if we re-raised the signal once we have
cleaned up any state that needs to be written before exiting?
Best Wishes
Phillip
next prev parent reply other threads:[~2023-09-14 13:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 10:03 [PATCH] rebase -i: ignore signals when forking subprocesses Phillip Wood via GitGitGadget
2023-09-07 12:57 ` Johannes Schindelin
2023-09-08 10:02 ` Phillip Wood
2023-09-10 8:24 ` Johannes Schindelin
2023-09-07 21:06 ` Jeff King
2023-09-08 9:59 ` Phillip Wood
2023-09-08 13:11 ` Phillip Wood
2023-09-10 10:05 ` Oswald Buddenhagen
2023-09-11 10:00 ` Phillip Wood
2023-09-11 10:14 ` Phillip Wood
2023-09-11 10:32 ` Oswald Buddenhagen
2023-09-13 15:33 ` Phillip Wood
2023-09-13 16:40 ` Oswald Buddenhagen
2023-09-14 9:56 ` Jeff King
2023-09-14 13:50 ` Phillip Wood [this message]
2023-09-07 21:16 ` 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=f7f29dc3-c5cb-4522-95db-1bf13bd1e416@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--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).