Linux PID recycling

LinuxPidRecycle

Linux Problem Overview


Is there any policy in Linux as to the recycling of used PIDs ? I mean, if a PId has been used, how much later will it be used again ?

Linux Solutions


Solution 1 - Linux

As new processes fork in, PIDs will increase to a system-dependent limit and then wrap around. The kernel will not reuse a PID before this wrap-around happens.

The limit (maximum number of pids) is /proc/sys/kernel/pid_max. The manual says:

> /proc/sys/kernel/pid_max (since Linux 2.5.34) > > This file 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

Solution 2 - Linux

https://superuser.com/questions/135007/how-are-pids-generated

This should answer your question - it appears it will recycle PIDs when it runs out, skipping the ones that are still assigned.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCygnusView Question on Stackoverflow
Solution 1 - LinuxcnicutarView Answer on Stackoverflow
Solution 2 - LinuxOsmium USAView Answer on Stackoverflow