15

What is the maximum and minimum value for a PID (Process ID) on Linux and Solaris?

Graeme
  • 251
  • 1
  • 2
  • 5
  • For linux, search " /proc/sys/kernel/pid_max" in https://man7.org/linux/man-pages/man5/proc.5.html – Rick May 26 '22 at 02:53

3 Answers3

17

From http://www.alexxoid.com/blog/linux/getting-the-max-pid-value-for-linux-process.html:

To get the max PID value that can be assigned to Linux process, run the following command:

cat /proc/sys/kernel/pid_max

On most Linux machines, the default value is 32768 (= 215).

However, it can be set to any value up to 4194304 (= 222) if necessary. Servers might have a larger limit to avoid PID collisions, for example.

Rick
  • 229
  • 1
  • 4
  • 14
16

You've had, and accepted, a Linux answer. On Solaris, the maximum value of a process ID is a kernel tunable parameter — pidmax in /etc/system — that defaults to 30,000 and that can be set anywhere between 266 and 999,999. Note that this is not max_nprocs, which is a kernel tunable parameter with a subtly different function.

JdeBP
  • 3,970
  • 17
  • 17
2

The minimum is 1 and usually the maximum is 2^15

  • ... except on Solaris, as in the question, where it isn't. – JdeBP Jun 10 '11 at 14:45
  • The minimum PID is actually 0, i.e. the kernel which isn't a process really ... – jlliagre Jun 10 '11 at 15:05
  • do the kernel get a PID? – Giovanni Tirloni Jun 13 '11 at 09:58
  • It doesn't need one but is given pid 0. Under Linux, I guess it is only shown as a PPID but under Solaris, there is definitely a /proc/0 entry and ps reports process 0 as "sched". – jlliagre Jun 14 '11 at 05:32
  • @jlliagre ubuntu has no `/proc/0` neither `ps -p 0` works :), anyway, as a variable pid initializer, the best seems to be `-1` – Aquarius Power Apr 17 '16 at 21:36
  • @AquariusPower but Linux does report anyway PID 0 as the parent process for at least `init` or `systemd`, plus `kthreadd`. See http://unix.stackexchange.com/questions/13290/init-process-ancestor-of-all-processes – jlliagre Apr 17 '16 at 22:40
  • @jlliagre interesting, the answer there also says that pid 0 means a process without parent, like a process running directly in the kernel; well, processes have to run in some environment that manages them, that is the kernel, therefore the self kernel cannot be a process inside of it-self. If a system gives access to pid 0 in some way, probably is to allow the user to query the kernel it-self, like a marker/indicator/reference, but not a process; that is what I think :) – Aquarius Power Apr 17 '16 at 23:08
  • @AquariusPower The kernel is indeed not a process or at least an extremely special one, but it is nevertheless given a process ID which is what the question is about. – jlliagre Apr 17 '16 at 23:46