Index: main/app.c =================================================================== --- main/app.c (revision 257768) +++ main/app.c (working copy) @@ -2005,6 +2005,7 @@ struct dirent *entry; snprintf(path, sizeof(path), "/proc/%d/fd", (int) getpid()); if ((dir = opendir(path))) { + fprintf(stderr, "Closing by /proc\n"); while ((entry = readdir(dir))) { /* Skip . and .. */ if (entry->d_name[0] == '.') { @@ -2016,7 +2017,12 @@ } closedir(dir); } else { + fprintf(stderr, "Closing by rlimit\n"); getrlimit(RLIMIT_NOFILE, &rl); + if (rl.rlim_cur > 65535) { + /* A more reasonable value */ + rl.rlim_cur = 65535; + } null = open("/dev/null", O_RDONLY); for (x = n + 1; x < rl.rlim_cur; x++) { if (x != null) {