Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the maximum value of the PID of a process?

Also, is it possible to change the PID of a running process?

share|improve this question
up vote 35 down vote accepted

On Linux, you can find the maximum PID value for your system with this:

$ cat /proc/sys/kernel/pid_max

This value can also be written using the same file, however the value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit:

$ echo 32768 > /proc/sys/kernel/pid_max

It seems to be normative practice on most 64 bit systems to set this value to the maximum 32 bit value, but this is by convention rather than a requirement.

From man 5 proc:

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

And no, you cannot change the PID of a running process. It gets assigned as a sequential number by the kernel at the time the process starts and that is it's identifier from that time on. The only thing you could do to get a new one is have your code fork a new process and terminate the old one.

share|improve this answer
and we can be sure of kernel bits with this – Aquarius Power Jun 12 '14 at 22:40
A curious semi-counterexample to the "cannot change the PID" story is the case of a multithreaded program, where one of the auxiliary threads does an exec(). It overlays the whole process, but changes the PID (to the TID of the exec'ing thread). – fche Apr 12 '15 at 22:11
The Maximum value of a PID for 32-bit machine is 32767, not 32768. 0 is the scheduler and 1 is init, and then user processes get 2 through 32767. – user129258 Aug 19 '15 at 7:07
@user129258 Read the proc man page for yourself, or cat the current value on you're own system. You'll find the value I used. The value you suggest is the maximum number of processes, not the maximum processes id of those processes. – Caleb May 11 at 4:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.