diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:16 -0800 |
commit | 5918bdcf26030a2540ac25d5b8cbee82fad219fc (patch) | |
tree | cb57d4f87ec162520e81f0b12ee114fbe55174fb /git.c | |
parent | 60dae46e42690dfb679abe9524d9f8efbfb45e7b (diff) | |
parent | 46df6906f3aaf74dafe2026b028c8c5c1a0d5f58 (diff) | |
download | git-5918bdcf26030a2540ac25d5b8cbee82fad219fc.tar.gz |
Merge branch 'jk/execv-dashed-external'
Typing ^C to pager, which usually does not kill it, killed Git and
took the pager down as a collateral damage in certain process-tree
structure. This has been fixed.
* jk/execv-dashed-external:
execv_dashed_external: wait for child on signal death
execv_dashed_external: stop exiting with negative code
execv_dashed_external: use child_process struct
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 36 |
1 files changed, 15 insertions, 21 deletions
@@ -575,8 +575,7 @@ static void handle_builtin(int argc, const char **argv) static void execv_dashed_external(const char **argv) { - struct strbuf cmd = STRBUF_INIT; - const char *tmp; + struct child_process cmd = CHILD_PROCESS_INIT; int status; if (get_super_prefix()) @@ -586,30 +585,25 @@ static void execv_dashed_external(const char **argv) use_pager = check_pager_config(argv[0]); commit_pager_choice(); - strbuf_addf(&cmd, "git-%s", argv[0]); + argv_array_pushf(&cmd.args, "git-%s", argv[0]); + argv_array_pushv(&cmd.args, argv + 1); + cmd.clean_on_exit = 1; + cmd.wait_after_clean = 1; + cmd.silent_exec_failure = 1; - /* - * argv[0] must be the git command, but the argv array - * belongs to the caller, and may be reused in - * subsequent loop iterations. Save argv[0] and - * restore it on error. - */ - tmp = argv[0]; - argv[0] = cmd.buf; - - trace_argv_printf(argv, "trace: exec:"); + trace_argv_printf(cmd.args.argv, "trace: exec:"); /* - * if we fail because the command is not found, it is - * OK to return. Otherwise, we just pass along the status code. + * If we fail because the command is not found, it is + * OK to return. Otherwise, we just pass along the status code, + * or our usual generic code if we were not even able to exec + * the program. */ - status = run_command_v_opt(argv, RUN_SILENT_EXEC_FAILURE | RUN_CLEAN_ON_EXIT); - if (status >= 0 || errno != ENOENT) + status = run_command(&cmd); + if (status >= 0) exit(status); - - argv[0] = tmp; - - strbuf_release(&cmd); + else if (errno != ENOENT) + exit(128); } static int run_argv(int *argcp, const char ***argv) |