git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] launch_editor: ignore SIGINT while the editor has control

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
Nov 7, 2012, 22:00 UTC
Message-ID
<20121107220027.GA17463@shrek.podlesie.net>
In-Reply-To
<20121107191652.842C52E8089@grass.foxharp.boston.ma.us>
On Wed, Nov 07, 2012 at 02:16:52PM -0500, Paul Fox wrote:
Show 28 quoted lines
> the user's editor likely catches SIGINT (ctrl-C).  but if the user
> spawns a command from the editor and uses ctrl-C to kill that command,
> the SIGINT will likely also kill git itself.  (depending on the
> editor, this can leave the terminal in an unusable state.)
> 
> Signed-off-by: Paul Fox <pgf@foxharp.boston.ma.us>
> 
>  editor.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/editor.c b/editor.c
> index d834003..775f22d 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -37,8 +37,12 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>  
>  	if (strcmp(editor, ":")) {
>  		const char *args[] = { editor, path, NULL };
> +		int ret;
>  
> -		if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
> +		sigchain_push(SIGINT, SIG_IGN);
> +		ret = run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env);
> +		sigchain_pop(SIGINT);
> +		if (ret)
>  			return error("There was a problem with the editor '%s'.",
>  					editor);
>  	}
Looks and works good, except for warnings:

editor.c: In function 'launch_editor': editor.c:42:3: warning: implicit declaration of function 'sigchain_push' [-Wimplicit-function-declaration] editor.c:44:3: warning: implicit declaration of function 'sigchain_pop' [-Wimplicit-function-declaration]

"sigchain.h" should be included, something like:
diff --git a/editor.c b/editor.c
index 775f22d..3ca361b 100644
--- a/editor.c
+++ b/editor.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "strbuf.h"
 #include "run-command.h"
+#include "sigchain.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"

Krzysiek
Previous: Paul FoxNext: Paul Fox
Message 2 of 4 in “launch_editor: ignore SIGINT while the editor has control”
  1. launch_editor: ignore SIGINT while the editor has controlPaul Fox, Nov 7, 2012
  2. Krzysztof MazurNov 7, 2012
  3. Paul FoxNov 7, 2012
  4. Jeff KingNov 8, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.