如何更改核心最大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).

相關內容