diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-01-20 22:30:52 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-01-20 22:30:52 -0500 |
commit | 5235a2a5a4d372cf7ebda7ccadf0325c7d4bad82 (patch) | |
tree | 7a150780fcaa85167a7d920dc2e6855a54bb7f85 /src/misc/getrlimit.c | |
parent | 26f38328d66f4bd525e9d21a9245ba4c54d6ca10 (diff) | |
download | musl-5235a2a5a4d372cf7ebda7ccadf0325c7d4bad82.tar.gz musl-5235a2a5a4d372cf7ebda7ccadf0325c7d4bad82.tar.xz musl-5235a2a5a4d372cf7ebda7ccadf0325c7d4bad82.zip |
use prlimit syscall for getrlimit/setrlimit
this allows the full range of 64-bit limit arguments even on 32-bit systems. fallback to the old syscalls on old kernels that don't support prlimit.
Diffstat (limited to 'src/misc/getrlimit.c')
-rw-r--r-- | src/misc/getrlimit.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/misc/getrlimit.c b/src/misc/getrlimit.c index 13835257..b7bbd062 100644 --- a/src/misc/getrlimit.c +++ b/src/misc/getrlimit.c @@ -1,14 +1,18 @@ #include <sys/resource.h> +#include <errno.h> #include "syscall.h" #include "libc.h" int getrlimit(int resource, struct rlimit *rlim) { - long k_rlim[2]; + unsigned long k_rlim[2]; + int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim); + if (!ret || errno != ENOSYS) + return ret; if (syscall(SYS_getrlimit, resource, k_rlim) < 0) return -1; - rlim->rlim_cur = k_rlim[0] == -1 ? -1 : (unsigned long)k_rlim[0]; - rlim->rlim_max = k_rlim[1] == -1 ? -1 : (unsigned long)k_rlim[1]; + rlim->rlim_cur = k_rlim[0] == -1UL ? RLIM_INFINITY : k_rlim[0]; + rlim->rlim_max = k_rlim[1] == -1UL ? RLIM_INFINITY : k_rlim[1]; return 0; } |