How to tell if a forked process is done?

Christos TZOTZIOY Georgiou tzot at
Thu Sep 25 01:16:58 CEST 2003

On Wed, 24 Sep 2003 22:30:36 +0000 (UTC), rumours say that Klaus
Alexander Seistrup <spam at> might have written:

>> if you are not root and you are sure that your own processes
>> do not breed like rabbits, then you can be almost sure that
>> os.kill(pid, 0) will throw an EPERM if your child has died.
>That's too many ifs to my taste.

I agree with that --that's what the 'almost' was about.  But...

>Your own processes needn't breed like rabbits - other's processes
>can breed like rabbits, too, and if you're unlucky, your next
>spawn will have the same pid as a previous process of yours. there is a little inconsistency with the flaw of this thread; I
discussed the chance of /another user's process/ using the pid of a
child between two kill(pid,0) attempts, not /another child/, because the
/original point/ was: parent process spawns a single child and then
checks for its existence (see also my mentioning of EPERM).  If anybody
mentioned multiple spawning of the parent process, I'm afraid the post
didn't show up in my newsreader.  Thus "your next spawn" seems not

>Anyway you look at it, killing blindly is bad programming practice.

Yes, it is; I have used kill(pid,0) in the past, aware that it's a quick
and dirty solution.  Semaphores are much more safe in such a situation.
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.

More information about the Python-list mailing list