diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a7b1a17fe10..6f4681f5fee 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2000-06-27 Andrew Haley + + * java/io/File.java (createTempFile): Close the FileDescriptor + used to create a temp file. Fixes some of PR 203. + * java/io/natFileDescriptorPosix.cc (open): Call garbage + collection if we run out of file handles. + 2000-06-28 Warren Levy * gnu/java/security/provider/Gnu.java: New file. diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java index 38bcb9f9c63..c8aaddfac2a 100644 --- a/libjava/java/io/File.java +++ b/libjava/java/io/File.java @@ -260,7 +260,9 @@ public class File implements Serializable String l = prefix + t.substring(t.length() - 6) + suffix; try { - desc.open (l, FileDescriptor.WRITE | FileDescriptor.EXCL); + desc = new FileDescriptor + (l, FileDescriptor.WRITE | FileDescriptor.EXCL); + desc.close (); ret.setPath(l); return ret; } diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc index 50be35c24be..6e06a034dd9 100644 --- a/libjava/java/io/natFileDescriptorPosix.cc +++ b/libjava/java/io/natFileDescriptorPosix.cc @@ -43,6 +43,7 @@ details. */ #include #include #include +#include #include #include #include @@ -105,6 +106,13 @@ java::io::FileDescriptor::open (jstring path, jint jflags) } int fd = ::open (buf, flags, mode); + if (fd == -1 && errno == EMFILE) + { + // Because finalize () calls close () we might be able to continue. + java::lang::System::gc (); + java::lang::System::runFinalization (); + fd = ::open (buf, flags, mode); + } if (fd == -1) { char msg[MAXPATHLEN + 200];