Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer

up vote 11 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. The maximum for 32 bit systems would be 32768, for 64 bit 4194304:

echo 32768 > /proc/sys/kernel/pid_max

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

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 what is the theoretical maximum for 64bit? – Dmitry Kodmov Jul 18 '11 at 14:02
See updated answer. – Caleb Jul 18 '11 at 14:15

Your Answer

 
discard

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.