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

Re: [PATCH 0/2] open() error checking

From
Thomas Rast <trast@inf.ethz.ch>
Date
Jul 16, 2013, 09:25 UTC
Message-ID
<87hafukga9.fsf@linux-k42r.v.cablecom.net>
In-Reply-To
<7vtxjzlmaf.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 19 quoted lines
> Thomas Rast <trast@inf.ethz.ch> writes:
>
>> I originally had a four-patch series to open 0/1/2 from /dev/null, but
>> then I noticed that this was shot down in 2008:
>>
>>   http://thread.gmane.org/gmane.comp.version-control.git/93605/focus=93896
>
> The way I recall the thread was not "shot down" but more like
> "fizzled out without seeing a clear consensus".  As a normal POSIX
> program, we do rely on fd#2 connected to an error stream, and I do
> agree with the general sentiment of that old thread that it is very
> wrong for warning() or die() to write to a pipe or file descriptor
> we opened for some other purpose, corrupting the destination.
>
> I briefly wondered if we can do the sanity check lazily (e.g. upon
> first warning() see of fd#2 is open and otherwise die silently), but
> we may open a fd (e.g. to create a new loose object) that may happen
> to grab fd#2 and then it is too late for us to do anything about it,
> so...

I think we'd have to do it on startup. Since we do many things already, a few extra dup calls should hardly matter.

I'll send the patches in reply in a minute, I had them lying around already. But if you (again) decide that it's not worth it, I don't care too deeply.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Junio C Hamano
Message 16 of 16 in “open() error checking”
  1. 0/2 open() error checkingThomas Rast, Jul 12, 2013
  2. 1/2 git_mkstemps: correctly test return value of open()Thomas Rast, Jul 12, 2013
  3. Thomas RastJul 16, 2013
  4. Junio C HamanoJul 17, 2013
  5. Drew NorthupJul 18, 2013
  6. Junio C HamanoJul 18, 2013
  7. Junio C HamanoJul 18, 2013
  8. Dale R. WorleyJul 18, 2013
  9. Eric SunshineJul 18, 2013
  10. Junio C HamanoJul 18, 2013
  11. Dale R. WorleyJul 18, 2013
  12. Junio C HamanoJul 18, 2013
  13. Dale R. WorleyJul 18, 2013
  14. 2/2 run-command: dup_devnull(): guard against syscalls failingThomas Rast, Jul 12, 2013
  15. Junio C HamanoJul 12, 2013
  16. Thomas RastJul 16, 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.