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

Re: [PATCH] setup: avoid unconditional open with write flags

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2022, 23:39 UTC
Message-ID
<xmqqr0xc85l4.fsf@gitster.g>
In-Reply-To
<f49b915e-46d1-7e53-ae4f-b01c2028b70d@web.de>
René Scharfe <l.s.r@web.de> writes:
> Can opening /dev/null (or NUL on Windows) multiple times instead of dup'ing
> cause issues?  Can we e.g. lock ourselves out?

258e93a1 (daemon: if one of the standard fds is missing open it to /dev/null, 2006-07-13) unfortunately does not explain why it was done this way.

Given that "command </dev/null >/dev/null 2>/dev/null" should work fine, I suspect that the "once we open a throw-away descriptor, instead of opening the same file again, dup the fd and reuse" was done not for correctness but for performance, under the assumption that open() is more expensive?

Previous: René Scharfe
Message 10 of 10 in “setup: avoid unconditional open with write flags”
  1. setup: avoid unconditional open with write flagsChristian Göttsche, Dec 5, 2022
  2. brian m. carlsonDec 5, 2022
  3. Jeff KingDec 6, 2022
  4. Christian GöttscheDec 6, 2022
  5. Taylor BlauDec 5, 2022
  6. Junio C HamanoDec 6, 2022
  7. Taylor BlauDec 6, 2022
  8. Junio C HamanoDec 6, 2022
  9. René ScharfeDec 6, 2022
  10. Junio C HamanoDec 6, 2022

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.