OLD | NEW |
(Empty) | |
| 1 #define _GNU_SOURCE |
| 2 #include <sys/resource.h> |
| 3 #include "syscall.h" |
| 4 #include "libc.h" |
| 5 |
| 6 #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) |
| 7 |
| 8 int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlim
it *old_limit) |
| 9 { |
| 10 struct rlimit tmp; |
| 11 int r; |
| 12 if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { |
| 13 tmp = *new_limit; |
| 14 FIX(tmp.rlim_cur); |
| 15 FIX(tmp.rlim_max); |
| 16 new_limit = &tmp; |
| 17 } |
| 18 r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit); |
| 19 if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { |
| 20 FIX(old_limit->rlim_cur); |
| 21 FIX(old_limit->rlim_max); |
| 22 } |
| 23 return r; |
| 24 } |
| 25 |
| 26 #undef prlimit64 |
| 27 LFS64(prlimit); |
OLD | NEW |