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