git: 1b8d70b2eb71 - main - kern: Introduce kern.pid_max_limit sysctl.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 30 Dec 2023 06:18:57 UTC
The branch main has been updated by pjd:
URL: https://cgit.FreeBSD.org/src/commit/?id=1b8d70b2eb713f5c75605419bb2505ce18fa304a
commit 1b8d70b2eb713f5c75605419bb2505ce18fa304a
Author: Pawel Jakub Dawidek <pjd@FreeBSD.org>
AuthorDate: 2023-12-30 06:15:17 +0000
Commit: Pawel Jakub Dawidek <pjd@FreeBSD.org>
CommitDate: 2023-12-30 06:15:17 +0000
kern: Introduce kern.pid_max_limit sysctl.
The kern.pid_max_limit will hold the PID_MAX value the kernel was
compiled with. The existing kern.pid_max sysctl can be modified and
doesn't really represent maximum PID number in the system, as there
may still be processes created with higher PIDs before kern.pid_max
was lowered.
Reivewed by: kib, zlei
Approved by: oshogbo
Differential Revision: https://reviews.freebsd.org/D43077
---
sys/kern/kern_mib.c | 4 ++++
sys/sys/proc.h | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index 5a95e3454ff2..b7a801cd53c0 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -754,6 +754,10 @@ SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT |
CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE,
0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid");
+SYSCTL_INT(_kern, OID_AUTO, pid_max_limit, CTLFLAG_RD,
+ SYSCTL_NULL_INT_PTR, PID_MAX,
+ "Maximum allowed pid (kern.pid_max) top limit");
+
#include <sys/bio.h>
#include <sys/buf.h>
SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index e7d2a1775603..33a878dc46aa 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -955,7 +955,7 @@ MALLOC_DECLARE(M_SUBPROC);
* in a pid_t, as it is used to represent "no process group".
*/
#define PID_MAX 99999
-#define NO_PID 100000
+#define NO_PID (PID_MAX + 1)
#define THREAD0_TID NO_PID
extern pid_t pid_max;