Jeff King <[email protected]> writes:
> Maybe the right rule is "if we are using the shell to execute, do not
> mention SIGPIPE"? It seems a little iffy at first, but:
>
> 1. It tends to coincide with direct use of internal tools versus
> external tools.
>
> 2. We do not reliably get SIGPIPE there, anyway, since most shells
> will convert it into exit code 141 before we see it.
>
> I.e., something like:
Hmph. That may be a good heuristics, but I wonder if we also want
to special case WIFEXITED(status) && WEXITSTATUS(status) == 141 to
pretend as if nothing went wrong, when ignore_sigpipe is in effect?
> diff --git a/run-command.c b/run-command.c
> index 24eaad5..8bd0b08 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -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)
> +static int wait_or_whine(pid_t pid, const char *argv0, int ignore_sigpipe)
> {
> int status, code = -1;
> pid_t waiting;
> @@ -242,7 +242,8 @@ static int wait_or_whine(pid_t pid, const char *argv0)
> error("waitpid is confused (%s)", argv0);
> } else if (WIFSIGNALED(status)) {
> code = WTERMSIG(status);
> - if (code != SIGINT && code != SIGQUIT)
> + if (code != SIGINT && code != SIGQUIT &&
> + (!ignore_sigpipe || code != SIGPIPE))
> error("%s died of signal %d", argv0, code);
> /*
> * This return value is chosen so that code & 0xff
> @@ -433,7 +434,7 @@ fail_pipe:
> * 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]);
> + wait_or_whine(cmd->pid, cmd->argv[0], 0);
> failed_errno = errno;
> cmd->pid = -1;
> }
> @@ -538,7 +539,7 @@ int finish_command(struct child_process *cmd)
>
> int finish_command(struct child_process *cmd)
> {
> - return wait_or_whine(cmd->pid, cmd->argv[0]);
> + return wait_or_whine(cmd->pid, cmd->argv[0], cmd->use_shell);
> }
>
> int run_command(struct child_process *cmd)
> @@ -725,7 +726,7 @@ int finish_async(struct async *async)
> int finish_async(struct async *async)
> {
> #ifdef NO_PTHREADS
> - return wait_or_whine(async->pid, "child process");
> + return wait_or_whine(async->pid, "child process", 0);
> #else
> void *ret = (void *)(intptr_t)(-1);
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html