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

Re: [PATCH] diff: fix textconv error zombies

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 30, 2010, 22:17 UTC
Message-ID
<201003310017.24979.j6t@kdbg.org>
In-Reply-To
<7vk4stv5y5.fsf@alter.siamese.dyndns.org>
On Dienstag, 30. März 2010, Junio C Hamano wrote:
> In "if necessary; see below", I tried to find something to help me judge
> why you said "That's really not _that_ important in this case", but I
> think I failed.  Perhaps we would want a bit more detailed discussion in
> the document there?

The "if necessary; see below" refers to the cases where the caller requests a file descriptor from start_command(). It is safe to follow the recipe. But I actually would not want to expand on the special case like we have in run_textconv, where it is not strictly necessary to close the fd before finish_command(), namely when we know that the writer will exit after it has closed its end of the pipe and the reader reads until EOF.

This could deadlock in the theoretical case that the read() in the parent returns an error even though the child is still writing data; the child would hang while waiting for the pipe being drained by the parent; but the parent would wait for the child to exit, which never happens. Doing the close() before finish_command() avoids this situation because the child dies of SIGPIPE.

But since the communication is via a pipe, and read failures are highly unlikely (and a read failure in a way that the writer does not fail, too, is even more unlikely, I think), the close() before finish_command() is "not important".

-- Hannes
Previous: Junio C HamanoNext: Jeff King
Message 9 of 19 in “fast textconv”
  1. 0/3 fast textconvJeff King, Mar 28, 2010
  2. 1/3 textconv: refactor calls to run_textconvJeff King, Mar 28, 2010
  3. 2/3 textconv: refactor to handle multiple textconv typesJeff King, Mar 28, 2010
  4. 3/3 diff: add "fasttextconv" config optionJeff King, Mar 28, 2010
  5. Johannes SixtMar 28, 2010
  6. Jeff KingMar 30, 2010
  7. diff: fix textconv error zombiesJohannes Sixt, Mar 30, 2010
  8. Junio C HamanoMar 30, 2010
  9. Johannes SixtMar 30, 2010
  10. Jeff KingMar 30, 2010
  11. Michael J GruberMar 28, 2010
  12. Jeff KingMar 28, 2010
  13. Jeff KingMar 28, 2010
  14. Jeff KingMar 28, 2010
  15. Jeff KingMar 28, 2010
  16. Sverre RabbelierMar 28, 2010
  17. Jeff KingMar 30, 2010
  18. Junio C HamanoMar 30, 2010
  19. Jeff KingMar 30, 2010

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.