Hi, It looks like Cygwin's implementation of setrlimit() does not check whether a "cur" value being set for a resource has been requested higher than the "max" value. It should have returned EINVAL.
From the documentation (Linux): EINVAL resource is not valid; or, for setrlimit(): rlim->rlim_cur was greater than rlim->rlim_max. Also noted for Linux in the "BUGS" section: Kernels before 2.4.22 did not diagnose the error EINVAL for setrlimit() when rlim->rlim_cur was greater than rlim->rlim_max. Test case: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/resource.h> int main(void) { struct rlimit rl; memset(&rl, 0, sizeof(rl)); rl.rlim_cur = 10; rl.rlim_max = 1; if (setrlimit(RLIMIT_CORE, &rl) != 0) perror("RLIMIT_CORE"); rl.rlim_cur = RLIM_INFINITY; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) perror("RLIMIT_NOFILE"); return 0; } Compilation: gcc -Wall test.c Execution in Cygwin: > ./a.exe (no output) Execution on Linux: > ./a.out RLIMIT_CORE: Invalid argument RLIMIT_NOFILE: Invalid argument The following patch is suggested for cygwin/resource.cc: *** resource.cc Wed May 1 14:10:28 2013 --- resource.cc.orig Mon Apr 8 21:04:52 2013 *************** setrlimit (int resource, const struct rl *** 173,181 **** if (getrlimit (resource, &oldlimits) < 0) return -1; ! if (rlp->rlim_cur > rlp->rlim_max) ! resource = RLIMIT_NLIMITS; // Catch default below, EINVAL ! else if (oldlimits.rlim_cur == rlp->rlim_cur && oldlimits.rlim_max == rlp->rlim_max) // No change in resource requirements, succeed immediately return 0; --- 173,179 ---- if (getrlimit (resource, &oldlimits) < 0) return -1; ! if (oldlimits.rlim_cur == rlp->rlim_cur && oldlimits.rlim_max == rlp->rlim_max) // No change in resource requirements, succeed immediately return 0; TIA, Anton Lavrentiev Contractor NIH/NLM/NCBI -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple