diff options
author | Karel Zak | 2011-10-28 00:23:59 +0200 |
---|---|---|
committer | Karel Zak | 2011-11-03 12:32:51 +0100 |
commit | 945ac25080493126d094731510b85bc2d90a1170 (patch) | |
tree | 15e92f972f9b46aff984477bebaf5e89eb284561 | |
parent | libuuid: fix includes in man pages (diff) | |
download | kernel-qcow2-util-linux-945ac25080493126d094731510b85bc2d90a1170.tar.gz kernel-qcow2-util-linux-945ac25080493126d094731510b85bc2d90a1170.tar.xz kernel-qcow2-util-linux-945ac25080493126d094731510b85bc2d90a1170.zip |
prlimit: add add falbacks
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | sys-utils/prlimit.c | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 36dffc727..49de07d98 100644 --- a/configure.ac +++ b/configure.ac @@ -854,6 +854,15 @@ UL_REQUIRES_HAVE([chcpu], [cpu_set_t], [cpu_set_t type]) AM_CONDITIONAL(BUILD_CHCPU, test "x$build_chcpu" = xyes) +UL_BUILD_INIT([prlimit], [check]) +UL_REQUIRES_LINUX([prlimit]) +UL_REQUIRES_SYSCALL_CHECK([prlimit], [UL_CHECK_SYSCALL([prlimit64])], [prlimit64]) +AM_CONDITIONAL(BUILD_PRLIMIT, test "x$build_prlimit" = xyes) +if test "x$build_prlimit" = xyes; then + AC_CHECK_FUNCS([prlimit]) +fi + + AC_ARG_ENABLE([switch_root], AS_HELP_STRING([--disable-switch_root], [do not build switch_root]), [], enable_switch_root=check diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index 74c7fc98e..2c7e6635e 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -33,6 +33,10 @@ #include "xalloc.h" #include "strutils.h" +#ifndef RLIMIT_RTTIME +# define RLIMIT_RTTIME 15 +#endif + enum { AS, CORE, @@ -123,6 +127,16 @@ static int columns[NCOLS], ncolumns; static pid_t pid; /* calling process (default) */ static int verbose; +#ifndef HAVE_PRLIMIT +# include <sys/syscall.h> +static int prlimit(pid_t p, int resource, + const struct rlimit *new_limit, + struct rlimit *old_limit) +{ + return syscall(SYS_prlimit, p, resource, new_limit, old_limit); +} +#endif + static void __attribute__ ((__noreturn__)) usage(FILE * out) { size_t i; |