- for (i=0; i<sizeof(LIMITS)/sizeof(LIMITS[0]); ++i) {
- struct rlimit limit;
-
- Egetrlimit(LIMITS[i].code, &limit);
- if (readSingleLimit(&limit, LIMITS[i].fname))
- Esetrlimit(LIMITS[i].code, &limit);
+ in_dir = true;
+ }
+ for (i=0; i<sizeof(LIMITS)/sizeof(LIMITS[0]); ++i) {
+ struct rlimit limit;
+
+ Egetrlimit(LIMITS[i].code, &limit);
+ /* if this arch uses sys_old_getrlimit... */
+ if (limit.rlim_cur == OLD_RLIM_INFINITY)
+ limit.rlim_cur = RLIM_INFINITY;
+ if (in_dir && readSingleLimit(&limit, LIMITS[i].fname))
+ Esetrlimit(LIMITS[i].code, &limit);
+ else if (LIMITS[i].code != RLIMIT_NOFILE) {
+ limit.rlim_max = RLIM_INFINITY;
+ Esetrlimit(LIMITS[i].code, &limit);
+ }
+ else {
+ /* RLIMIT_NOFILE can't be set to infinity, 1024*1024 seems to be the limit in most kernels */
+ limit.rlim_max = 1024*1024;
+ setrlimit(LIMITS[i].code, &limit);