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

Re: [PATCH 2/2] Check for IO errors after running a command

From
Jim Meyering <jim@meyering.net>
Date
Jun 25, 2007, 14:01 UTC
Message-ID
<877ipsw2sz.fsf@rho.meyering.net>
In-Reply-To
<7vy7i8xtap.fsf@assigned-by-dhcp.pobox.com>
Junio C Hamano <gitster@pobox.com> wrote:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
...
Show 17 quoted lines
>> For example, then we could just do
>>
>> 	status = p->fn(...);
>> 	if (status)
>> 		return status;
>> 	/* Somebody closed stdout? */
>> 	if (fstat(fileno(stdout), &st))
>> 		return 0;
>> 	/* Ignore write errors for pipes and sockets.. */
>> 	if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode))
>> 		return 0;
>>
>> which makes it easy to explain what's going on, and avoids having any deep
>> indentation at all.
>
> I took the liberty of munging your two patches to follow your
> comments above

That has the disadvantage of ignoring *all* pipe and socket write errors. IMHO, git would be better served if it didn't do that, since writing to those can fail with EIO and even a new one: EACCES (though this latter is only for sockets). Also possible, according to POSIX: ENOBUFS.

Of course, one can probably argue that those are all unlikely. They may be even less likely than an actual EPIPE, but the point is that people and tools using git plumbing should be able to rely on it to report such write failures, no matter how unusual they are.

Previous: Johannes SixtNext: Linus Torvalds
Message 9 of 13 in “(resend) [PATCH] Don't ignore write failure from git-diff, git-log, etc.”
  1. Jim MeyeringJun 23, 2007
  2. Junio C HamanoJun 24, 2007
  3. Linus TorvaldsJun 24, 2007
  4. 1/2 Clean up internal command handlingLinus Torvalds, Jun 24, 2007
  5. 2/2 Check for IO errors after running a commandLinus Torvalds, Jun 24, 2007
  6. Junio C HamanoJun 25, 2007
  7. Johannes SchindelinJun 25, 2007
  8. Johannes SixtJun 25, 2007
  9. Jim MeyeringJun 25, 2007
  10. Linus TorvaldsJun 25, 2007
  11. Matthias LederhoferJun 26, 2007
  12. Jim MeyeringJun 25, 2007
  13. Jim MeyeringJun 24, 2007

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.