bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: du, file descriptors


From: Jim Meyering
Subject: Re: du, file descriptors
Date: Mon, 12 May 2003 17:24:52 +0200

Tim Waugh <address@hidden> wrote:
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=90563
>
> Try this:
>
> rm -rf arena; mkdir arena; cd arena
> seq 1 1024 | xargs touch
> du -s *
>
> I get this near the end of the output:
> du: cannot open current directory: Too many open files
>
> During the ./configure run the fd limit was detected as 1019.

Thank you both!
That was due to a bug in my changes to ftw.c.

FWIW, this exposes another limitation (albeit minor) resulting
from the use of nftw: in your example, `.' is opened and closed
once for each file.  With an fts-like implementation it might make
sense to add logic to avoid the extra open calls, when possible.

Here's the fix:

        * ftw.c (ftw_startup): Always call free_cwd after restore_cwd.
        Reported by Matti Aarnio as
        https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=90563.
        Forwarded by Tim Waugh.

Index: lib/ftw.c
===================================================================
RCS file: /fetish/cu/lib/ftw.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -p -u -r1.27 -r1.28
--- lib/ftw.c   5 May 2003 07:54:19 -0000       1.27
+++ lib/ftw.c   12 May 2003 14:51:02 -0000      1.28
@@ -813,6 +813,7 @@ ftw_startup (const char *dir, int is_nft
          save_err = errno;
          result = -1;
        }
+      free_cwd (&cwd);
 
       __set_errno (save_err);
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]