How to tell if a forked process is done?

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Wed Sep 24 13:09:49 EDT 2003


On Wed, 24 Sep 2003 09:52:45 -0400, rumours say that François Pinard
<pinard at iro.umontreal.ca> might have written:

>> This will yield a false positive and potential damage if the OS has
>> spawned another process with the same pid, and running under your uid,
>> as the task you wanted to supervise.
>
>Granted in theory, yet this does not seem to be considered a real
>problem in practice.  To generate another process with the same pid, the
>system would need to generate so many intermediate processes that the
>process counter would overflow and come back to its current value.  The
>`kill(pid, 0)' trick is still the way people seem to do it.
>
>Do you know anything reasonably simple, safer, and that does the job?

Not that simple: a semaphore.
Not that safe: the existence of a semaphore file.

kill(pid,0) is ok; but a pipe and select would be useful too, safe and
relatively simple (for old Unix programmers at least :).
-- 
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.




More information about the Python-list mailing list