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
This commit is contained in:
Pawel Jakub Dawidek 2023-12-29 22:15:17 -08:00
parent 84b4342c0d
commit 1b8d70b2eb
2 changed files with 5 additions and 1 deletions

View File

@ -754,6 +754,10 @@ SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT |
CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE,
0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); 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/bio.h>
#include <sys/buf.h> #include <sys/buf.h>
SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD, SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD,

View File

@ -955,7 +955,7 @@ MALLOC_DECLARE(M_SUBPROC);
* in a pid_t, as it is used to represent "no process group". * in a pid_t, as it is used to represent "no process group".
*/ */
#define PID_MAX 99999 #define PID_MAX 99999
#define NO_PID 100000 #define NO_PID (PID_MAX + 1)
#define THREAD0_TID NO_PID #define THREAD0_TID NO_PID
extern pid_t pid_max; extern pid_t pid_max;