如何更改内核最大PID号?

drp*_*eas 11 linux process kernel limit

默认 PID 最大数为 32768。要获取此信息,请键入:

cat /proc/sys/kernel/pid_max 
32768
Run Code Online (Sandbox Code Playgroud)

或者

sysctl kernel.pid_max
kernel.pid_max = 32768
Run Code Online (Sandbox Code Playgroud)

现在,我想改变这个数字……但我不能。好吧,实际上我可以将其更改为较低的值或相同的值。例如:

linux-6eea:~ # sysctl -w  kernel.pid_max=32768
kernel.pid_max = 32768
Run Code Online (Sandbox Code Playgroud)

但是我不能用大于 32768 的值来做。例如:

linux-6eea:~ # sysctl -w  kernel.pid_max=32769
error: "Invalid argument" setting key "kernel.pid_max"
Run Code Online (Sandbox Code Playgroud)

有任何想法吗 ?

PS:我的内核是 Linux linux-6eea 3.0.101-0.35-pae #1 SMP Wed Jul 9 11:43:04 UTC 2014 (c36987d) i686 i686 i386 GNU/Linux

Jan*_*Jan 12

该值只能扩展到 32 位系统的理论最大值 32768 或 64 位系统的 4194304。

来自man 5 proc

/proc/sys/kernel/pid_max  
  This file (new in Linux 2.5) specifies the value at which PIDs wrap around
  (i.e., the value in this file is one greater than the maximum PID). The
  default value for this file, 32768, results in the same range of PIDs as
  on earlier kernels. On 32-bit platfroms, 32768 is the maximum value for
  pid_max. On 64-bit systems, pid_max can be set to any value up to 2^22
  (PID_MAX_LIMIT, approximately 4 million).
Run Code Online (Sandbox Code Playgroud)