git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH] avoid SIGPIPE warnings for aliases

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 10, 2013, 20:22 UTC
Message-ID
<7vbocw23fq.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130110112655.GB21993@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 10 quoted lines
> 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?

Show 50 quoted lines
> 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);
>  
Previous: Jeff KingNext: Jeff King
Message 18 of 23 in “avoid SIGPIPE warnings for aliases”
  1. avoid SIGPIPE warnings for aliasesJeff King, Jan 4, 2013
  2. Johannes SixtJan 4, 2013
  3. Jeff KingJan 4, 2013
  4. Junio C HamanoJan 4, 2013
  5. Jeff KingJan 5, 2013
  6. run-command: encode signal death as a positive integerJeff King, Jan 5, 2013
  7. Johannes SixtJan 5, 2013
  8. Jonathan NiederJan 5, 2013
  9. Jeff KingJan 5, 2013
  10. Jonathan NiederJan 5, 2013
  11. Junio C HamanoJan 6, 2013
  12. Junio C HamanoJan 9, 2013
  13. Jeff KingJan 9, 2013
  14. Junio C HamanoJan 9, 2013
  15. Jonathan NiederJan 10, 2013
  16. Junio C HamanoJan 10, 2013
  17. Jeff KingJan 10, 2013
  18. Junio C HamanoJan 10, 2013
  19. Jeff KingJan 10, 2013
  20. Johannes SixtJan 10, 2013
  21. Junio C HamanoJan 10, 2013
  22. Jeff KingJan 10, 2013
  23. mimimimiJul 21, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.