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

Re: [REGRESSION] git-wrapper to run-commands codepath regression

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 18, 2011, 22:17 UTC
Message-ID
<20110418221720.GA16977@elie>
In-Reply-To
<7v4o5v8dlp.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 5 quoted lines
>     	if (write(...))
>     		; /* yes, yes, there was an error. */
>
> No, a non-zero return is not an error from the write(2) system call.
> I cannot believe both of us didn't spot it.  What were we smoking?
Yagh.
	if (write(child_err, "fatal: ", 7) ||
	    write(child_err, msg, len) ||
	    write(child_err, "\n", 1))
		; /* yes, gcc -D_FORTIFY_SOURCE, we know there was an error. */
There are two unusual conditions in which this could fail:
 - it doesn't write anything at all, in which case the return value
   is -1.
 - a partial write, for example if writing to an almost-full pipe.
I suppose in a calmer time, a better fix will look like
	if (write_in_full(child_err, "fatal: ", 7) != 7 ||
	    write_in_full(child_err, msg, len) != len ||
	    write_in_full(child_err, "\n", 1) != 1)
		/* yes, yes, ...
and gcc will have told us something potentially useful.
Thanks for catching it.
Previous: Junio C HamanoNext: Jonathan Nieder
Message 9 of 20 in “[REGRESSION] git-wrapper to run-commands codepath regression”
  1. Junio C HamanoApr 18, 2011
  2. Jeff KingApr 18, 2011
  3. Jeff KingApr 18, 2011
  4. Junio C HamanoApr 18, 2011
  5. Jeff KingApr 18, 2011
  6. Junio C HamanoApr 18, 2011
  7. Andreas SchwabApr 18, 2011
  8. Junio C HamanoApr 18, 2011
  9. Jonathan NiederApr 18, 2011
  10. run-command: write full error message in die_childJonathan Nieder, Apr 19, 2011
  11. Johannes SixtApr 20, 2011
  12. 0/2 Re: run-command: write full error message in die_childJonathan Nieder, Apr 20, 2011
  13. 1/2 tests: check error message from run_commandJonathan Nieder, Apr 20, 2011
  14. 2/2 run-command: handle short writes and EINTR in die_childJonathan Nieder, Apr 20, 2011
  15. Junio C HamanoApr 19, 2011
  16. report which $PATH entry had trouble running execvp(3)Junio C Hamano, Apr 20, 2011
  17. Jeff KingApr 20, 2011
  18. Junio C HamanoApr 21, 2011
  19. Johannes SixtApr 20, 2011
  20. Jonathan NiederApr 20, 2011

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.