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

Re: [PATCH v2 1/2] perl: redirect stderr to /dev/null instead of closing

From
Petr Baudis <pasky@ucw.cz>
Date
Apr 6, 2013, 10:34 UTC
Message-ID
<20130406103426.GE6137@machine.or.cz>
In-Reply-To
<878v4wrsj7.fsf@linux-k42r.v.cablecom.net>
On Sat, Apr 06, 2013 at 10:07:40AM +0200, Thomas Rast wrote:
Show 7 quoted lines
> The manpage for dup2 does, however, say
> 
>    If newfd was open, any errors  that  would  have  been  reported  at
>    close(2) time are lost.  A careful programmer will not use dup2() or
>    dup3() without closing newfd first.
> 
> which is probably what you were referring to.

Yes, that's probably one reason why I had this stuck in my mind (though, how often does anyone bother to detect errors on close()...? ;-).

Funnily enough, POSIX.2008 specifies that if closing newfd would fail, dup2() reports EIO and newfd is not closed, eliminating this problem.

The manpage does not cover this; well, that's fair enough as Linux just doesn't care and never does that if I didn't miss anything in the code.

-- 
			Petr "Pasky who might even send
				a patch, but the matter is
				oh so obscure" Baudis
Previous: Thomas RastNext: Thomas Rast
Message 9 of 11 in “perl: redirect stderr to /dev/null instead of closing”
  1. perl: redirect stderr to /dev/null instead of closingThomas Rast, Apr 3, 2013
  2. Eric WongApr 4, 2013
  3. 1/2 perl: redirect stderr to /dev/null instead of closingThomas Rast, Apr 4, 2013
  4. Eric WongApr 4, 2013
  5. Petr BaudisApr 5, 2013
  6. Junio C HamanoApr 5, 2013
  7. Petr BaudisApr 5, 2013
  8. Thomas RastApr 6, 2013
  9. Petr BaudisApr 6, 2013
  10. 2/2 t9700: do not close STDERRThomas Rast, Apr 4, 2013
  11. Jonathan NiederApr 4, 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.