Will process ids be recycled? What if you reach the maximal id

kernelprocess

Process IDs are strictly increasing, but if your system runs long enough and there is a lot of processes terminating and starting, you could at some point reach the limit of the underlying integral type (on my system it seems to be a signed int) where no larger pid would exists. Would this cause old unused ids (of processes that finished) to be recycled (i.e. handed out a second time)? What if somebody is waiting for that pid to terminate but didn't check in a looong time?

Best Answer

Process IDs are not strictly increasing on any UNIX-like operating system I know of. Your question is based on a false assumption.

The only requirements on process IDs are:

A process ID shall not be reused by the system until the process lifetime ends. In addition, if there exists a process group whose process group ID is equal to that process ID, the process ID shall not be reused by the system until the process group lifetime ends. A process that is not a system process shall not have a process ID of 1.

Related Question