diff options
-rw-r--r-- | arch/i386/bits/syscall.h | 2 | ||||
-rw-r--r-- | include/sys/resource.h | 8 | ||||
-rw-r--r-- | src/misc/prlimit.c | 8 |
3 files changed, 18 insertions, 0 deletions
diff --git a/arch/i386/bits/syscall.h b/arch/i386/bits/syscall.h index 8d673186..1147e9f3 100644 --- a/arch/i386/bits/syscall.h +++ b/arch/i386/bits/syscall.h @@ -470,6 +470,7 @@ static inline long __syscall6(long __n, long __a1, long __a2, long __a3, long __ #define __NR_inotify_init1 332 #define __NR_preadv 333 #define __NR_pwritev 334 +#define __NR_prlimit64 340 /* fixup legacy 16-bit junk */ #undef __NR_lchown @@ -881,6 +882,7 @@ static inline long __syscall6(long __n, long __a1, long __a2, long __a3, long __ #define SYS_inotify_init1 332 #define SYS_preadv 333 #define SYS_pwritev 334 +#define SYS_prlimit64 340 /* fixup legacy 16-bit junk */ #undef SYS_lchown diff --git a/include/sys/resource.h b/include/sys/resource.h index b9189028..cb39923f 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -9,6 +9,10 @@ extern "C" { #define __NEED_time_t #define __NEED_struct_timeval +#ifdef _GNU_SOURCE +#define __NEED_pid_t +#endif + #include <bits/alltypes.h> typedef unsigned long long rlim_t; @@ -49,6 +53,10 @@ int getrusage (int, struct rusage *); int getpriority (int, id_t); int setpriority (int, id_t, int); +#ifdef _GNU_SOURCE +int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); +#endif + #define PRIO_PROCESS 0 #define PRIO_PGRP 1 #define PRIO_USER 2 diff --git a/src/misc/prlimit.c b/src/misc/prlimit.c new file mode 100644 index 00000000..b9dbb446 --- /dev/null +++ b/src/misc/prlimit.c @@ -0,0 +1,8 @@ +#include <unistd.h> +#include <sys/resource.h> +#include "syscall.h" + +int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) +{ + return syscall(SYS_prlimit64, pid, resource, new_limit, old_limit); +} |