From e662df7e830a9d93ca36b74a7b5e670e139b0da1 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 7 Jul 2020 14:17:14 +0200 Subject: Wait for child on signal death for aliases to builtins When you hit ^C all the processes in the tree receives it. When a git command uses a pager, git ignores this and waits until the pager quits. However, when using an alias there is an additional process in the tree which didn't ignore the signal. That caused it to exit which in turn caused the pager to exit. This fixes that for aliases to builtins. This was originally fixed in 46df6906 (execv_dashed_external: wait for child on signal death, 2017-01-06), but was broken by ee4512ed (trace2: create new combined trace facility, 2019-02-22) and then b9140840 (git: avoid calling aliased builtins via their dashed form, 2019-07-29). Signed-off-by: Trygve Aaberge Signed-off-by: Junio C Hamano --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git.c') diff --git a/git.c b/git.c index 7be7ad34bd..9b8d3c92e6 100644 --- a/git.c +++ b/git.c @@ -768,7 +768,7 @@ static int run_argv(int *argcp, const char ***argv) * OK to return. Otherwise, we just pass along the status code. */ i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE | - RUN_CLEAN_ON_EXIT, "git_alias"); + RUN_CLEAN_ON_EXIT | RUN_WAIT_AFTER_CLEAN, "git_alias"); if (i >= 0 || errno != ENOENT) exit(i); die("could not execute builtin %s", **argv); -- cgit v1.2.3 From c0d73a59c956ace5e02c9f0fab336ac4dbe64102 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 7 Jul 2020 14:17:15 +0200 Subject: Wait for child on signal death for aliases to externals When we are running an alias to an external command, we want to wait for that process to exit even after receiving ^C which normally kills the git process. This is useful when the process is ignoring SIGINT (which e.g. pagers often do), and then we don't want it to be killed. Having an alias which invokes a pager is probably not common, but it can be useful e.g. if you have an alias to a git command which uses a subshell as one of the arguments (in which case you have to use an external command, not an alias to a builtin). This patch is similar to the previous commit, but the previous commit fixed this only for aliases to builtins, while this commit does the same for aliases to external commands. In addition to waiting after clean like the previous commit, this also enables cleaning the child (that was already enabled for aliases to builtins before the previous commit), because wait_after_clean relies on it. Lastly, while the previous commit fixed a regression, I don't think this has ever worked properly. Signed-off-by: Trygve Aaberge Signed-off-by: Junio C Hamano --- git.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git.c') diff --git a/git.c b/git.c index 9b8d3c92e6..c0698c7d45 100644 --- a/git.c +++ b/git.c @@ -345,6 +345,8 @@ static int handle_alias(int *argcp, const char ***argv) commit_pager_choice(); child.use_shell = 1; + child.clean_on_exit = 1; + child.wait_after_clean = 1; child.trace2_child_class = "shell_alias"; argv_array_push(&child.args, alias_string + 1); argv_array_pushv(&child.args, (*argv) + 1); -- cgit v1.2.3