"mute" <datatwirl@gis.net> wrote:
i was playing with my sysetem, and i noticed that each process id for the same command running consequtively (like "ls;ls;ls;ls;<so on>) is incremented by one from the previous, like pid of first ls for example is 31200, second 31201, and so on. so my question is this. do these pid's get recycled in anyway?
After 32767 (= 2^15 - 1 = 0x7fff) the PIDs for new processes start again at 300 [1]. PIDs that are still assigned to processes (or sessions or process groups) are skipped.
(why my ls wouldnt run with the same pid each time, if no other process uses that particular pid?)
The time before a PID is reused should not be to short. This could cause confusions with other running programs that use a PID after the corresponding process terminated, because they could erroneously refer to a newly created process instead.
or do they keep on being incremented until some certain value, and then reset?
Yes, see above. If you are interested in details and know how to read C code then have a look at the function get_pid in /usr/src/linux/kernel/fork.c ;-) Eilert [1] Many processes started shortly after the system startup are deamons that will run permanently. Reusing PIDs starting with 300 will in many cases skip most of this processes. This increases the performance when checking for the next free PID because it reduces the probability of hitting a used one. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Eilert Brinkmann -- Universitaet Bremen -- FB 3, Informatik eilert@informatik.uni-bremen.de - eilert@tzi.org - eilert@linuxfreak.com http://www.informatik.uni-bremen.de/~eilert/ -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq