this is where potential bugs lie
ZXNet echo conference «zxnet.pc»
From Aleksandr Majorov → To Kirill Frolov 27 November 2001
Hello Kirill!
26 Nov 01 22:43, Kirill Frolov -> All:
KF> For example, I have a script. The script calculates using cunning
KF> manipulation of which PID he needs to nail down, well, he nails it. What if
KF> for example, the process being killed will die in the process of calculating its PID
Once the PID has been calculated, remember it, then check
for the presence and current then kill ;)
KF> and a completely different process with the same PID will be born?
KF> Everything will go wrong, smoke will come out of the system unit and screws
KF> are formatted.
KF> How to get around this?
How many bits is your PID?
Minimum 16 bits == 65536 processes.
The system has a counter “what next PID can be issued”
And this counter only works incrementally.
So in order to get a process with the same PID
65536 more processes need to be launched.
(Although actually less - minus the number of already running ones;)
What is the probability that you have between calculating PID and checking
its presence and killing will launch another 65536 processes - count it yourself ;))
PS: what I wrote above is an approximate answer that was given to me.
WHEN I was interested in your question ;)
Alexand