X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=editor.c;h=27bdecdaf3d99d3179737e07be971d2458408660;hb=47adb8ac7c550bc89e7eae743dcc8940c2549edf;hp=d8340031d24828483697c10257806efedfe041f5;hpb=bac9c06ba093d9254cb2ab3eed074722a3e635a6;p=git.git diff --git a/editor.c b/editor.c index d8340031d..27bdecdaf 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" @@ -37,8 +38,25 @@ 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, sig; - if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env)) + 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); + sigchain_push(SIGQUIT, SIG_IGN); + ret = finish_command(&p); + sig = ret - 128; + sigchain_pop(SIGINT); + sigchain_pop(SIGQUIT); + if (sig == SIGINT || sig == SIGQUIT) + raise(sig); + if (ret) return error("There was a problem with the editor '%s'.", editor); }