git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Kalle Olavi Niemitalo <kon@iki.fi>
Cc: Paul Fox <pgf@foxharp.boston.ma.us>, git@vger.kernel.org
Subject: Re: What's cooking in git.git (Nov 2012, #02; Fri, 9)
Date: Sun, 11 Nov 2012 10:48:46 -0500	[thread overview]
Message-ID: <20121111154846.GA13188@sigill.intra.peff.net> (raw)
In-Reply-To: <87wqxs4o6f.fsf@Niukka.kon.iki.fi>

On Sun, Nov 11, 2012 at 09:02:48AM +0200, Kalle Olavi Niemitalo wrote:

> If git did the same thing as cvs here, i.e. ignore the signals in
> the parent process only and check the exit status of the editor,
> I think that would be OK.

Silly me. When I thought through the impact of Paul's patch, I knew that
we would notice signal death of the editor. But I totally forgot to
consider that the blocked signal is inherited by the child process. I
think we just need to move the signal() call to after we've forked. Like
this (on top of Paul's patch):

diff --git a/editor.c b/editor.c
index 3ca361b..0ed23ce 100644
--- a/editor.c
+++ b/editor.c
@@ -38,11 +38,20 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 
 	if (strcmp(editor, ":")) {
 		const char *args[] = { editor, path, NULL };
+		struct child_process p;
 		int ret;
 
+		memset(&p, 0, sizeof(p));
+		p.argv = args;
+		p.env = env;
+		p.use_shell = 1;
+		if (start_command(&p) < 0)
+			return error("unable to start editor '%s'", editor);
+
 		sigchain_push(SIGINT, SIG_IGN);
-		ret = run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env);
+		ret = finish_command(&p);
 		sigchain_pop(SIGINT);
+
 		if (ret)
 			return error("There was a problem with the editor '%s'.",
 					editor);

Note that this will give you a slightly verbose message from git.
Potentially we could notice editor death due to SIGINT and suppress the
message, under the assumption that the user hit ^C and does not need to
be told.

-Peff

  parent reply	other threads:[~2012-11-11 15:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09 19:23 What's cooking in git.git (Nov 2012, #02; Fri, 9) Jeff King
2012-11-09 20:01 ` Ralf Thielow
2012-11-09 20:06   ` Ralf Thielow
2012-11-09 20:10     ` Jeff King
2012-11-09 20:27       ` Junio C Hamano
2012-11-10  0:38         ` Jeff King
2012-11-10 17:14           ` Junio C Hamano
2012-11-09 21:52 ` Kalle Olavi Niemitalo
2012-11-10 15:52   ` Paul Fox
2012-11-10 19:32     ` Kalle Olavi Niemitalo
2012-11-10 21:12       ` Andreas Schwab
2012-11-10 22:08       ` Paul Fox
2012-11-11  7:02         ` Kalle Olavi Niemitalo
2012-11-11  8:58           ` Andreas Schwab
2012-11-11 15:48           ` Jeff King [this message]
2012-11-11 16:31             ` [PATCH 0/5] ignore SIGINT while editor runs Jeff King
2012-11-11 16:55               ` [PATCH 1/5] launch_editor: refactor to use start/finish_command Jeff King
2012-11-11 16:55               ` [PATCH 2/5] launch_editor: ignore SIGINT while the editor has control Paul Fox
2012-11-12 17:44                 ` Junio C Hamano
2012-11-12 19:47                   ` Jeff King
2012-11-11 16:55               ` [PATCH 3/5] run-command: drop silent_exec_failure arg from wait_or_whine Jeff King
2012-11-11 18:13                 ` Felipe Contreras
2012-11-11 16:56               ` [PATCH 4/5] run-command: do not warn about child death by SIGINT Jeff King
2012-11-11 16:57               ` [PATCH 5/5] launch_editor: propagate SIGINT from editor to git Jeff King
2012-11-11 19:48                 ` Johannes Sixt
2012-11-30 20:24                   ` Jeff King
2012-11-11 16:58               ` [PATCH 2/5] launch_editor: ignore SIGINT while the editor has control Jeff King
2012-11-11 18:27               ` [PATCH 0/5] ignore SIGINT while editor runs Paul Fox
2012-11-11 19:15               ` Krzysztof Mazur
2012-11-11 20:24                 ` Paul Fox
2012-11-11 20:43                   ` Krzysztof Mazur
2012-11-11 22:08                     ` Andreas Schwab
2012-11-09 23:21 ` What's cooking in git.git (Nov 2012, #02; Fri, 9) Felipe Contreras
2012-11-10  0:33   ` Jeff King
2012-11-10  0:44     ` Felipe Contreras
2012-11-10 12:32     ` SZEDER Gábor
2012-11-10 19:13       ` Felipe Contreras
2012-11-10 19:56       ` 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=20121111154846.GA13188@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=kon@iki.fi \
    --cc=pgf@foxharp.boston.ma.us \
    /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).