Non-random PIDs

Jason Dixon jason at dixongroup.net
Sun Aug 1 19:21:37 UTC 2004


I remember reading a long time ago about how Linux doesn't randomize 
new process ID's, in the way that OpenBSD (among others, I hope) does.  
Is there anyone here who follows Linux kernel development closely that 
might know why this hasn't happened yet, or perhaps know when it will?

If this is a feature of 2.6, please excuse my ignorance.  My tests have 
all been performed on 2.4 kernels.  Note that this behavior is also 
found on Mac OS X.

Example fork.pl on Whitebox Linux (RHEL 3) running 2.4.21-15.0.3.ELsmp:

[root at colo2 root]# while true; do perl fork.pl; sleep 1; done
I'm the child and my pid is 21116. my parent is 21115
I'm the parent and my pid is 21115.  My child is 21116
I'm the child and my pid is 21119. my parent is 21118
I'm the parent and my pid is 21118.  My child is 21119
I'm the child and my pid is 21122. my parent is 21121
I'm the parent and my pid is 21121.  My child is 21122
I'm the child and my pid is 21125. my parent is 21124
I'm the parent and my pid is 21124.  My child is 21125
I'm the child and my pid is 21128. my parent is 21127
I'm the parent and my pid is 21127.  My child is 21128

Example fork.pl on OpenBSD 3.4 -stable:

bash-2.05b# while true; do perl fork.pl; sleep 1; done
I'm the parent and my pid is 21142.  My child is 11841
I'm the child and my pid is 11841. my parent is 21142
I'm the parent and my pid is 9919.  My child is 13316
I'm the child and my pid is 13316. my parent is 9919
I'm the parent and my pid is 19968.  My child is 4416
I'm the child and my pid is 4416. my parent is 19968
I'm the parent and my pid is 14416.  My child is 8937
I'm the child and my pid is 8937. my parent is 14416
I'm the parent and my pid is 1940.  My child is 917
I'm the child and my pid is 917. my parent is 1940

Thanks,

--
Jason Dixon, RHCE
DixonGroup Consulting
http://www.dixongroup.net





More information about the redhat-list mailing list