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

Re: Bug: Failure if stdin is closed.

From
DWDale Worley <worley@c-66-31-108-177.hsd1.ma.comcast.net>
Date
Jul 11, 2013, 17:21 UTC
Message-ID
<201307111721.r6BHLiXD013670@freeze.ariadne.com>
In-Reply-To
<87r4f52jjf.fsf@linux-k42r.v.cablecom.net>
> From: Thomas Rast <trast@inf.ethz.ch>
> May I ask why you need this, and to what extent this problem cannot be
> solved by instead redirecting from/to /dev/null?
The situation in which the problem arose is described here:
Show 5 quoted lines
> worley@alum.mit.edu (Dale R. Worley) writes:
> 
> > (The original problem and the discussion that ensued is on the
> > git-users mailing list:
> > https://groups.google.com/forum/#!topic/git-users/lNQ7Cn35EqA)

It involves invoking git from Apache. I haven't read up on the details because I didn't need to in order to debug the problem.

Show 5 quoted lines
> Closing 2 usually has even funkier consequences if the program proceeds
> to open some other file, it ends up as fd 2, and it then dies with an
> error.  In that sense it might be saner to simply die whenever open()
> gives an FD in the 0..2 range (and we weren't explicitly trying to
> reopen one of them).

True... But fd 2 may be needed under many unpredictable circumstances. In regard to fd 0, we can predict that standard input (per se) will not be needed, so it's anti-robust to require that it be open for the code to function at all.

> However, does it fully fix the issue you describe?  What if you then run
> 'git checkout -F -' to read the message from stdin?

Obviously, if the git command explicitly requires use of standard-input, then standard-input needs to be open.

Show 10 quoted lines
> > However, when looking at the code, I noticed that few of the functions
> > have comments describing what they do, and none describe their input
> > and output values.  In particular, there are no comments specifying
> > what the error return values are.  This is appalling for a supposedly
> > professional-quality project!
> 
> You are touching on a sore point of the git code base.  Some
> contributors have made a point of adding comments where appropriate, so
> we're improving, but round tuits are in short supply as always.  If you
> can supply such tuits, they would be appreciated.
I will try to put my money where my mouth is.
Dale
Previous: Thomas Rast
Message 3 of 3 in “Bug: Failure if stdin is closed.”
  1. Dale R. WorleyJul 11, 2013
  2. Thomas RastJul 11, 2013
  3. Dale WorleyJul 11, 2013

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.