Linux手册上说:
/proc/sys/kernel/pid_max (since Linux 2.5.34)
This file specifies the value at which PIDs wrap around (i.e., the value in this file is one greater than the maximum PID). PIDs greater than this value are not allocated; thus, the value in this file also acts as a system-wide limit on the total number of processes and threads. The default value for this file, 32768, results in the same range of PIDs as on earlier kernels. On 32-bit platforms, 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).
PID的最大值默认是short类型的最大值加1(Linux手册规定的加1),因为short是有符号类型,所以2个字节能表示的最大值是2 ^ 15 - 1,加上1之后为32768。
可以使用命令:cat proc/sys/kernel/pid_max查看。