------- Comment #10 from ktietz at gcc dot gnu dot org 2010-04-24 12:02 ------- So I investigated this issue about mktemp in more detail and found finally the first-scope and second-scope bug here.
Old logic was opening files and as long as mktemp failed on a second call, things were working (the re-initialization of the template was missing, so one of the following calls will failed). As side-effect there were many file handles generated, which weren't closed. Tested patch is Index: unix.c =================================================================== --- unix.c (revision 158676) +++ unix.c (working copy) @@ -889,25 +889,26 @@ template = get_mem (strlen (tempdir) + 20); +#ifdef HAVE_MKSTEMP sprintf (template, "%s/gfortrantmpXXXXXX", tempdir); -#ifdef HAVE_MKSTEMP - fd = mkstemp (template); #else /* HAVE_MKSTEMP */ - - if (mktemp (template)) - do + fd = -1; + do + { + sprintf (template, "%s/gfortrantmpXXXXXX", tempdir); + if (!mktemp (template)) + break; #if defined(HAVE_CRLF) && defined(O_BINARY) fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IREAD | S_IWRITE); #else fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE); #endif - while (!(fd == -1 && errno == EEXIST) && mktemp (template)); - else - fd = -1; + } + while (fd == -1 && errno == EEXIST); #endif /* HAVE_MKSTEMP */ Ok for applying it to trunk, 4.5, and 4.4? Kai -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43844