Re: [PATCH] detect dup failure
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Jun 27, 2007, 12:48 UTC
- Message-ID
- <81b0412b0706270548p6f694fd6x5f47cbefa16c08ac@mail.gmail.com>
- In-Reply-To
- <87wsxpobf0.fsf@rho.meyering.net>
On 6/27/07, Jim Meyering <jim@meyering.net> wrote:
> Without this, if you ever run out of file descriptors, dup will > fail (silently), fdopen will return NULL, and fprintf will > try to dereference NULL (i.e., usually segfault).
But if you check the result of fdopen for NULL instead you'll cover the dup failure _and_ out-of-memory in one go. You'll loose the errno (probably), but you don't seem to use it here anyway.