aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_mib.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2012-08-15 15:56:21 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2012-08-15 15:56:21 +0000
commit02c6fc211417512a7239e30e954cce046b19d81f (patch)
treea9682200639371dd135caf82e8d5130aa117d0c2 /sys/kern/kern_mib.c
parenta055e7ceb48de82e8b682f6036e99704383072dd (diff)
downloadsrc-02c6fc211417512a7239e30e954cce046b19d81f.tar.gz
src-02c6fc211417512a7239e30e954cce046b19d81f.zip
Add a sysctl kern.pid_max, which limits the maximum pid the system is
allowed to allocate, and corresponding tunable with the same name. Note that existing processes with higher pids are left intact. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=239301
Diffstat (limited to 'sys/kern/kern_mib.c')
-rw-r--r--sys/kern/kern_mib.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index 75b3af936d0e..f6ab3a4a5526 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -499,6 +499,30 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD,
SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD,
0, sizeof(struct proc), "sizeof(struct proc)");
+static int
+sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS)
+{
+ int error, pm;
+
+ pm = pid_max;
+ error = sysctl_handle_int(oidp, &pm, 0, req);
+ if (error || !req->newptr)
+ return (error);
+ sx_xlock(&proctree_lock);
+ sx_xlock(&allproc_lock);
+ /* Only permit the values less then PID_MAX. */
+ if (pm > PID_MAX)
+ error = EINVAL;
+ else
+ pid_max = pm;
+ sx_xunlock(&allproc_lock);
+ sx_xunlock(&proctree_lock);
+ return (error);
+}
+SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN |
+ CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I",
+ "Maximum allowed pid");
+
#include <sys/bio.h>
#include <sys/buf.h>
SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,