diff --git a/ImageMagick.spec b/ImageMagick.spec
index d3a89e6..78be29a 100644
--- a/ImageMagick.spec
+++ b/ImageMagick.spec
@@ -1,5 +1,5 @@
 %define VERSION  6.5.5
-%define Patchlevel  8
+%define Patchlevel  9
 
 Name:           ImageMagick
 Version:        %{VERSION}
diff --git a/config/configure.xml b/config/configure.xml
index 78bf1a8..da0939e 100644
--- a/config/configure.xml
+++ b/config/configure.xml
@@ -8,7 +8,7 @@
 <configuremap>
   <configure name="NAME" value="ImageMagick"/>
   <configure name="LIB_VERSION" value="0x655"/>
-  <configure name="LIB_VERSION_NUMBER" value="6,5,5,8"/>
+  <configure name="LIB_VERSION_NUMBER" value="6,5,5,9"/>
   <configure name="RELEASE_DATE" value="2009-09-08"/>
   <configure name="CONFIGURE" value="./configure "/>
   <configure name="PREFIX" value="/usr/local"/>
diff --git a/configure b/configure
index a04fd5f..baff623 100755
--- a/configure
+++ b/configure
Binary files differ
diff --git a/configure.ac b/configure.ac
index f525790..9893526 100755
--- a/configure.ac
+++ b/configure.ac
@@ -984,7 +984,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_VPRINTF
 
-AC_CHECK_FUNCS([_exit atexit clock clock_gettime directio execvp floor fork ftime ftruncate getcwd getpid getexecname getdtablesize getpagesize getrusage gettimeofday gmtime_r localtime_r lstat memmove memset mkstemp munmap _NSGetExecutablePath pclose _pclose poll popen _popen posix_fadvise posix_fallocate posix_madvise posix_memalign pow pread pwrite raise rand_r readlink readdir_r realpath select seekdir setlocale sqrt setvbuf stat strchr strerror_r strrchr strcspn strdup strpbrk strspn strstr strtol symlink sysconf sigemptyset sigaction strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times usleep vsprintf vsnprintf waitpid _wfopen _wstat])
+AC_CHECK_FUNCS([_exit atexit clock clock_gettime directio execvp floor fork ftime ftruncate getcwd getpid getexecname getdtablesize getpagesize getrlimit getrusage gettimeofday gmtime_r localtime_r lstat memmove memset mkstemp munmap _NSGetExecutablePath pclose _pclose poll popen _popen posix_fadvise posix_fallocate posix_madvise posix_memalign pow pread pwrite raise rand_r readlink readdir_r realpath select seekdir setlocale sqrt setvbuf stat strchr strerror_r strrchr strcspn strdup strpbrk strspn strstr strtol symlink sysconf sigemptyset sigaction strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times usleep vsprintf vsnprintf waitpid _wfopen _wstat])
 
 ########
 #
diff --git a/libtool b/libtool
index c3c0975..4d9e86b 100755
--- a/libtool
+++ b/libtool
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # libtool - Provide generalized library-building support services.
-# Generated automatically by config.status (ImageMagick) 6.5.5-8
+# Generated automatically by config.status (ImageMagick) 6.5.5-9
 # Libtool was configured on host magick.imagemagick.org:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
diff --git a/magick/resource.c b/magick/resource.c
index 5b45c62..6ca29d8 100644
--- a/magick/resource.c
+++ b/magick/resource.c
@@ -762,9 +762,23 @@
   files=(-1);
 #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
   files=sysconf(_SC_OPEN_MAX);
-#elif defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
-  files=getdtablesize();
 #endif
+#if defined(MAGICKCORE_HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
+  if (files < 0)
+    {
+      struct rlimit
+        resources;
+
+      if (getrlimit(RLIMIT_NOFILE,&resources) != -1)
+        files=resources.rlim_cur;
+  }
+#endif
+#if defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
+  if (files < 0)
+    files=getdtablesize();
+#endif
+  if (files < 0)
+    files=64;
   (void) SetMagickResourceLimit(FileResource,MagickMax((unsigned long)
     (3*files/4),64));
   limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
diff --git a/magick/version.h b/magick/version.h
index 1b17b82..097d320 100644
--- a/magick/version.h
+++ b/magick/version.h
@@ -30,7 +30,7 @@
 #define MagickLibVersion  0x655
 #define MagickLibVersionText  "6.5.5"
 #define MagickLibVersionNumber  2,0,0
-#define MagickLibSubversion  "-8"
+#define MagickLibSubversion  "-9"
 #define MagickReleaseDate  "2009-09-08"
 #define MagickChangeDate   "20090907"
 #define MagickAuthoritativeURL  "http://www.imagemagick.org"