[svlug] Reuse of pid's.

Karen Shaeffer shaeffer at neuralscape.com
Wed Jan 21 21:05:59 PST 2009


On Wed, Jan 21, 2009 at 01:33:32PM -0800, Bill Ward wrote:
> On Wed, Jan 21, 2009 at 11:59 AM, Greg Lindahl <lindahl at pbm.com> wrote:
> > On Wed, Jan 21, 2009 at 11:20:12AM -0800, Don Marti wrote:
> >
> >> Not really, since you don't know what pid the kernel
> >> will give the next process it creates.
> >
> > 'cept they're traditionally handed out round-robin, which is why
> > killall works most of the time. It's only when you have a very fast
> > rate of process creation that you get into trouble.
> 
> Right, and so if you have process creation happening that fast, such
> that a PID which was recently freed is already to be used again,
> you've got bigger problems than this.

Hi,
Consider a process that the kernel launches with a new pid. Assume
this process persists for a long time. The kernel will continue to
issue new pid's that are greater than our hypothetical process's pid.
And the kernel will eventually wrap back to the very low pids and start
ascending the pid list again. And eventually the kernel will be issuing
new pid's that are close to our hypothetical process's pid but less than
it. And if you kill our hypothetical process at this moment, then the
kernel may very well re-issue that pid very soon after it was freed.

There are many ways to solve this problem. One useful tidbit is to
fork a test probe and collect it's pid. Now you know where the kernel
is in the pid cycle. There are many other ways as well. Norm might want
to learn about the proc filesystem, because the kernel exports a wealth
of information about the currently running processes there.

Thanks,
Karen
-- 
 Karen Shaeffer
 Neuralscape, Palo Alto, Ca. 94306
 shaeffer at neuralscape.com  http://www.neuralscape.com




More information about the svlug mailing list