[ovs-dev] [PATCH] daemon: Avoid leaking file descriptor in close_standard_fds()

Simon Horman horms at verge.net.au
Tue Sep 6 23:04:33 UTC 2011


On Tue, Sep 06, 2011 at 10:07:27AM -0700, Ben Pfaff wrote:
> On Mon, Sep 05, 2011 at 01:20:40PM +0900, Simon Horman wrote:
> > There is no need to keep null_fd open once
> > it has been used by the three dup2() calls.
> 
> get_null_fd() caches the null file descriptor to return on the next
> call, so this will cause the next call to get_null_fd() to return a
> bad file descriptor (or one that has been reused).
> 
> It's probably not a huge win for get_null_fd() to cache the null file
> descriptor, so if you want to change that semantic it would be OK with
> me, but as-is I think that this patch would break things (specifically
> process_start()).

Opps, my bad. I missed that null_fd is static.

Personally I have a slight preference to make null_fd non-static and close
it at the end of get_null_fd() to have one less open fd lying around.
I will send an updated patch for consideration.



More information about the dev mailing list