mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'pf/editor-ignore-sigint'
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: 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
This commit is contained in:
commit
d5b95853c2
20
editor.c
20
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);
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ static inline void set_cloexec(int fd)
|
|||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
||||
}
|
||||
|
||||
static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
|
||||
static int wait_or_whine(pid_t pid, const char *argv0)
|
||||
{
|
||||
int status, code = -1;
|
||||
pid_t waiting;
|
||||
|
@ -242,7 +242,8 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
|
|||
error("waitpid is confused (%s)", argv0);
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
code = WTERMSIG(status);
|
||||
error("%s died of signal %d", argv0, code);
|
||||
if (code != SIGINT && code != SIGQUIT)
|
||||
error("%s died of signal %d", argv0, code);
|
||||
/*
|
||||
* This return value is chosen so that code & 0xff
|
||||
* mimics the exit code that a POSIX shell would report for
|
||||
|
@ -432,8 +433,7 @@ int start_command(struct child_process *cmd)
|
|||
* At this point we know that fork() succeeded, but execvp()
|
||||
* failed. Errors have been reported to our stderr.
|
||||
*/
|
||||
wait_or_whine(cmd->pid, cmd->argv[0],
|
||||
cmd->silent_exec_failure);
|
||||
wait_or_whine(cmd->pid, cmd->argv[0]);
|
||||
failed_errno = errno;
|
||||
cmd->pid = -1;
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ int start_command(struct child_process *cmd)
|
|||
|
||||
int finish_command(struct child_process *cmd)
|
||||
{
|
||||
return wait_or_whine(cmd->pid, cmd->argv[0], cmd->silent_exec_failure);
|
||||
return wait_or_whine(cmd->pid, cmd->argv[0]);
|
||||
}
|
||||
|
||||
int run_command(struct child_process *cmd)
|
||||
|
|
Loading…
Reference in a new issue