[svlug] Reuse of pid's.

Don Marti dmarti at zgp.org
Fri Jan 23 08:58:51 PST 2009

begin Karen Shaeffer quotation of Thu, Jan 22, 2009 at 10:19:34PM -0800:

> There is no queue. The kernel saves the value of the last pid allocated,
> and increases from there looking for the next pid. When it rolls over, it
> cycles through the list again, and again. 

And it does it fast -- about 10,000 pids/s on my Core
2 Duo, 1.60GHz.

A malicious user can make it more likely that
"killall" will kill the wrong process by writing a
little program to keep forking and checking the child
pid until the value sneaks up on the target process.

(Sometimes a daemon will have a command-line
option to tell it not to go into the background.
One way to avoid the killall would be to invoke
it with that option, under start-stop-daemon, and
have start-stop-daemon handle putting it into the
background after creating a pidfile.)

Don Marti                                        +1 510-814-0932
http://zgp.org/~dmarti/                          +1 510-332-1587 mobile
dmarti at zgp.org
See you at OpenSource World: August 10-13, 2009 in San Francisco

More information about the svlug mailing list