Too many open files

Iain Buclaw ibuclaw at ubuntu.com
Thu Oct 25 08:35:25 PDT 2012


On 25 October 2012 16:17, Joseph Rushton Wakeling
<joseph.wakeling at webdrake.net> wrote:
> Hello all,
>
> I have some code which needs to read in data from a large number of files in
> a directory.
>
> The basic data input code goes something like this:
>
>     foreach(DirEntry e; dirEntries(...))
>     {
>         auto f = file(e.name, "r");
>         // we input data from f.
>     }
>
> This runs fine with ldc and dmd.  However, if I compile with gdc (4.6.3) I
> get the following error while running the program:
>
> ------------------------------------------------------------------------------
> std.exception.ErrnoException at ../../../src/libphobos/std/stdio.d(330): Cannot
> open file in mode `r' (Too many open files)
> ------------------------------------------------------------------------------
>
> This is trivial to work around by putting an explicit f.close() at the end
> of the loop, but it looks like a bug to me as f should in any case
> automatically be closed at the end of the scope -- no?
>
> I don't see a bug report on BitBucket about this, but thought I'd check here
> first in case this is something that has already been fixed in the latest
> version.
>

Don't raise a bug in bitbucket, it'll only be ignored...


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the D.gnu mailing list