source:
EcnlProtoTool/trunk/musl-1.1.18/src/linux/prlimit.c
Last change on this file was 444, checked in by , 4 years ago | |
---|---|
|
|
File size: 675 bytes |
Line | |
---|---|
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 rlimit *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); |
Note:
See TracBrowser
for help on using the repository browser.