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

Re: [PATCH] start_command(), if .in/.out > 0, closes file descriptors, not the callers

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 17, 2008, 08:20 UTC
Message-ID
<20080217082049.GT24004@spearce.org>
In-Reply-To
<7vodag2egp.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > Of course the same argument can be said for fd 0; if the parent does
> > close(0) before some other open/socket/pipe call then its obviously
> > possible for the parent to get a fd that it wants the child to take
> > over and close.
> >
> > We're basically assuming that the parent will always keep its
> > own stdin open if it will be spawning children.  We all know what
> > happens when we assume (we double close file descriptors) but I
> > think its a reasonable safe assumption to be making.
> 
> Ok, that unwritten assumption was what confused me.  We
> definitely need Documentation/technical/api-*.txt before any
> more code, don't you agree?
Yes.

I'm far too tired to write it tonight. Maybe I will find the time and energy tomorrow. Depends on how it goes at day-job (yes, must go back for yet another day this weekend).

But this API is messy enough that we need explicit rules of how it should be used, and then make everyone match that.

Unless Johannes Sixt beats me to it, my next patch to you will be for a proposed documentation improvement.

-- 
Shawn.
Previous: Junio C HamanoNext: Johannes Sixt
Message 11 of 15 in “Automatically close stderr pipes created by run_command”
  1. 2/6 Automatically close stderr pipes created by run_commandShawn O. Pearce, Feb 14, 2008
  2. Johannes SixtFeb 14, 2008
  3. Junio C HamanoFeb 15, 2008
  4. Johannes SixtFeb 15, 2008
  5. Junio C HamanoFeb 15, 2008
  6. start_command(), .in/.out/.err = -1: Callers must close the file descriptorJohannes Sixt, Feb 16, 2008
  7. start_command(), if .in/.out > 0, closes file descriptors, not the callersJohannes Sixt, Feb 16, 2008
  8. Junio C HamanoFeb 16, 2008
  9. Shawn O. PearceFeb 17, 2008
  10. Junio C HamanoFeb 17, 2008
  11. Shawn O. PearceFeb 17, 2008
  12. Johannes SixtFeb 17, 2008
  13. start_command(), if .in/.out > 0, closes file descriptors, not the callersJohannes Sixt, Feb 21, 2008
  14. Junio C HamanoFeb 22, 2008
  15. Junio C HamanoFeb 16, 2008

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.