What is the maximum and minimum value for a PID (Process ID) on Linux and Solaris?
3 Answers
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.
- 229
- 1
- 4
- 14
- 343
- 3
- 7
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.
- 3,970
- 17
- 17
-
You mentioned that `max_nprocs` is different, what's the difference? – ffledgling Mar 14 '17 at 11:52
-
2@ffledgling `max_nprocs` limits the number of concurrent processes, regardless of whether unused pids are available or not. – jlliagre May 18 '18 at 10:26
The minimum is 1 and usually the maximum is 2^15
-
-
The minimum PID is actually 0, i.e. the kernel which isn't a process really ... – jlliagre Jun 10 '11 at 15:05
-
-
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