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).
Let's ignore it while the editor is running, and do the same
for SIGQUIT, which many editors also ignore. This matches
the behavior if we were to use system(3) instead of
run-command.
Signed-off-by: Paul Fox <pgf@foxharp.boston.ma.us>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
#include "cache.h"
#include "strbuf.h"
#include "run-command.h"
#include "cache.h"
#include "strbuf.h"
#include "run-command.h"
#ifndef DEFAULT_EDITOR
#define DEFAULT_EDITOR "vi"
#ifndef DEFAULT_EDITOR
#define DEFAULT_EDITOR "vi"
if (strcmp(editor, ":")) {
const char *args[] = { editor, path, NULL };
struct child_process p;
if (strcmp(editor, ":")) {
const char *args[] = { editor, path, NULL };
struct child_process p;
memset(&p, 0, sizeof(p));
p.argv = args;
memset(&p, 0, sizeof(p));
p.argv = args;
if (start_command(&p) < 0)
return error("unable to start editor '%s'", editor);
if (start_command(&p) < 0)
return error("unable to start editor '%s'", editor);
- if (finish_command(&p))
+ sigchain_push(SIGINT, SIG_IGN);
+ sigchain_push(SIGQUIT, SIG_IGN);
+ ret = finish_command(&p);
+ sigchain_pop(SIGINT);
+ sigchain_pop(SIGQUIT);
+ if (ret)
return error("There was a problem with the editor '%s'.",
editor);
}
return error("There was a problem with the editor '%s'.",
editor);
}