]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
prlimit: add add falbacks
authorKarel Zak <kzak@redhat.com>
Thu, 27 Oct 2011 22:23:59 +0000 (00:23 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Nov 2011 11:32:51 +0000 (12:32 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
sys-utils/prlimit.c

index 36dffc7276eb93953fdf7270ba789ee0a364a6c9..49de07d9829597de7e094f1c02c6c265dfc3f86f 100644 (file)
@@ -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
index 74c7fc98e271ade8ab85ffad8b8c12e004f66c46..2c7e6635e526df09448a27eb9da8832b951985fa 100644 (file)
 #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;