[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fts: slightly more robust
From: |
Jim Meyering |
Subject: |
Re: fts: slightly more robust |
Date: |
Thu, 03 Sep 2009 20:19:40 +0200 |
Eric Blake wrote:
> Eric Blake <ebb9 <at> byu.net> writes:
>> Here's the latest draft of my patch.
>
> While we're at it, I noticed via findutils that fts leaks fds into child
> processes. This plugs the fts leak (but completely fixing find also requires
> a
> patch to findutils).
>
> Hmm - POSIX states that fdopendir can, but not must, set the cloexec flag, as
> part of consuming the fd. Maybe the gnulib fdopendir module should guarantee
> that the cloexec flag is set as part of creating a directory stream, rendering
> the first of the three hunks to fts.c redundant? Or maybe keep the fdopendir
> module as-is, but create a new module fdopendir-gnu, which goes further and
> gives the additional GNU semantics that: fd is changed to cloexec, and dirfd
> gives the same fd back (requires tweaking rpl_opendir on mingw to open an fd
> up
> front, and for all other platforms lacking fdopendir it requires writing into
> the member variable read by dirfd).
>
>
> From: Eric Blake <address@hidden>
> Date: Wed, 2 Sep 2009 14:44:51 -0600
> Subject: [PATCH] fts: avoid leaking fds
>
> * modules/fts (Depends-on): Add cloexec.
> * lib/fts.c (opendirat, diropen, fts_build): Set close-on-exec
> flag.
>
> Signed-off-by: Eric Blake <address@hidden>
> ---
> ChangeLog | 5 +++++
> lib/fts.c | 18 ++++++++++++++----
> modules/fts | 1 +
> 3 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index e63e020..3933600 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,10 @@
> 2009-09-02 Eric Blake <address@hidden>
>
> + fts: avoid leaking fds
> + * modules/fts (Depends-on): Add cloexec.
> + * lib/fts.c (opendirat, diropen, fts_build): Set close-on-exec
> + flag.
Looks fine. Thanks!