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 PID recycling [closed]
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
OK. So this increasing policy is followed strictly ? Or it can reuse a PID before the limit has been reached ? –
Bradfordbradlee
I thought a pid had been reused before the wrap, but after
ps -A -L -o lwp |sort -n
I found pids about 32372 were still in use; so my guess is it is wrapping around very fast on my system! even if not too often, but at least on boot. –
Triboluminescence 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.
© 2022 - 2024 — McMap. All rights reserved.
top
without worrying about how PIDs are recycled. – Novice