Skip to content

Commit

Permalink
kern: Introduce kern.pid_max_limit sysctl.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Pawel Jakub Dawidek authored and Pawel Jakub Dawidek committed Dec 30, 2023
1 parent 84b4342 commit 1b8d70b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sys/kern/kern_mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sys/sys/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1b8d70b

Please sign in to comment.