如何更改内核最大PID号?

如何更改内核最大PID号?

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

cat /proc/sys/kernel/pid_max 
32768

或者

sysctl kernel.pid_max
kernel.pid_max = 32768

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

linux-6eea:~ # sysctl -w  kernel.pid_max=32768
kernel.pid_max = 32768

但我不能对大于 32768 的值执行此操作。例如:

linux-6eea:~ # sysctl -w  kernel.pid_max=32769
error: "Invalid argument" setting key "kernel.pid_max"

有任何想法吗 ?

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

答案1

对于 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).

相关内容