From: Phillip Wood <phillip.wood123@gmail.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>, git@vger.kernel.org
Cc: thomas.wolf@paranor.ch, Alexander Veit <alexander.veit@gmx.net>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] editor: only save (and restore) the terminal if using a tty
Date: Tue, 23 Nov 2021 11:05:16 +0000 [thread overview]
Message-ID: <b1f2257a-044c-17bb-2737-42b8026421eb@gmail.com> (raw)
In-Reply-To: <20211122222850.674-1-carenas@gmail.com>
Hi Carlo
On 22/11/2021 22:28, Carlo Marcelo Arenas Belón wrote:
> If the editor is invoked without a controlling terminal, then
> saving the state and restoring it later is not very useful and
> could generate signals that the invoking process wouldn't know
> how to handle.
>
> if git's standard output is not connected to a terminal, then
> presume there is no need to worry if the invoking terminal could
> garble it.
Checking if stdout is a terminal fixes the Eclipse case where stdout is
a pipe or /dev/null but if git is started in the background from a
terminal then calling isatty() will not prevent git from receiving
SIGTTOU. For example if the user is using a gui editor then the
following used to work
GIT_EDITOR=gedit git commit&
Now git receives SIGTTOU when the editor exits because we call
tcsetattr() from a background process group. One can argue it does not
make much sense to be starting git in the background but it did work
before these changes. I think a combination of isatty() and tcgetpgrp()
is probably the best solution.
Best Wishes
Phillip
> Reported-by: Alexander Veit <alexander.veit@gmx.net>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> editor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/editor.c b/editor.c
> index 674309eed8..214e3834cb 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -86,7 +86,7 @@ static int launch_specified_editor(const char *editor, const char *path,
> p.env = env;
> p.use_shell = 1;
> p.trace2_child_class = "editor";
> - term_fail = save_term(1);
> + term_fail = isatty(1) ? save_term(1) : 1;
> if (start_command(&p) < 0) {
> if (!term_fail)
> restore_term();
>
next prev parent reply other threads:[~2021-11-23 11:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 8:42 Update to Git 2.34.0 breaks application Alexander Veit
2021-11-22 21:43 ` Phillip Wood
2021-11-22 22:28 ` [PATCH] editor: only save (and restore) the terminal if using a tty Carlo Marcelo Arenas Belón
2021-11-22 22:47 ` Junio C Hamano
2021-11-22 23:03 ` Junio C Hamano
2021-11-22 23:08 ` Junio C Hamano
2021-11-23 8:52 ` Alexander Veit
2021-11-23 9:08 ` Carlo Arenas
2021-11-22 23:39 ` Carlo Arenas
2021-11-23 17:35 ` Junio C Hamano
2021-11-24 13:29 ` Johannes Schindelin
2021-11-24 18:25 ` Carlo Arenas
2021-11-24 19:34 ` Junio C Hamano
2021-11-24 20:04 ` Carlo Arenas
2021-11-24 20:51 ` Junio C Hamano
2021-11-29 21:12 ` Johannes Schindelin
2021-11-23 11:05 ` Phillip Wood [this message]
2021-11-23 17:27 ` Junio C Hamano
2021-11-23 17:31 ` Carlo Arenas
2021-11-30 11:07 ` Phillip Wood
2021-12-01 5:12 ` Chris Torek
2021-12-01 19:33 ` Junio C Hamano
2021-12-02 0:38 ` Junio C Hamano
2021-12-02 1:51 ` Carlo Arenas
2021-12-02 14:48 ` Johannes Schindelin
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=b1f2257a-044c-17bb-2737-42b8026421eb@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=alexander.veit@gmx.net \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=thomas.wolf@paranor.ch \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.