svn commit: r291114 - head/lib/libc/gen

Ravi Pokala rpokala at mac.com
Fri Nov 20 23:57:54 UTC 2015


-----Original Message-----


From: Andrey Chernov <ache at freebsd.org>
Date: 2015-11-20, Friday at 15:20
To: Ravi Pokala <rpokala at FreeBSD.org>, <src-committers at freebsd.org>, <svn-src-all at freebsd.org>, <svn-src-head at freebsd.org>
Subject: Re: svn commit: r291114 - head/lib/libc/gen

>On 21.11.2015 1:36, Ravi Pokala wrote:
>>   Move fdopen() up near other resource allocation like malloc(); do proper
>>   deallocation on failure later on in the function.
>
>Incorrect. Old code calls fdopen() only in the parent, new one calls
>fdopen() before fork(), so its results shared by both parent and child,
>which is wrong for child() case.

There's two different things at play - userland resources and kernel resources. Both "FILE *iop" and "struct pid *cur" are userland, while the descriptors in "pdes" are kernel. We clean up the descriptors in "pdes" in call cases, so we're not leaking kernel resources. You're right that "iop" (and "cur", which you didn't mention) appear to be leaked in the child, in that they're not explicitly cleaned up. But they get wiped away by the _execve(), so it doesn't matter.

-Ravi



More information about the svn-src-head mailing list