diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-01-14 07:32:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-14 07:32:25 -0800 |
commit | 659742f796b5502e3917fbdbd1d7400c9648b180 (patch) | |
tree | 981af89e83e9e8dd0d2b89e813f17bc708a5c26e /editor.c | |
parent | Merge branch 'mk/maint-graph-infinity-loop' into maint (diff) | |
parent | fix compilation with NO_PTHREADS (diff) | |
download | tgif-659742f796b5502e3917fbdbd1d7400c9648b180.tar.xz |
Merge branch 'pf/editor-ignore-sigint' into maint
The behaviour visible to the end users was confusing, when they
attempt to kill a process spawned in the editor that was in turn
launched by Git with SIGINT (or SIGQUIT), as Git would catch that
signal and die. We ignore these signals now.
* pf/editor-ignore-sigint:
fix compilation with NO_PTHREADS
launch_editor: propagate signals from editor to git
run-command: do not warn about child death from terminal
launch_editor: ignore terminal signals while editor has control
launch_editor: refactor to use start/finish_command
run-command: drop silent_exec_failure arg from wait_or_whine
Diffstat (limited to 'editor.c')
-rw-r--r-- | editor.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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); } |