Zombies from forked thread process. Why?
donn at drizzle.com
Thu Aug 16 07:06:07 CEST 2001
Quoth Dave Cinege <dcinege at psychosis.com>:
| Linux 2.4, Debian 2.2/Redhat 7.1 Python 2.1.1 compiled from source.
| I have a daemon process that watches a directory for files. When
| some appear it decides what to do with them and then spawns a
| processor to handle them. To be speedy it detaches (forks) a processor
| for each 'section'. Eveything run perfect, except that when the processor
| process returns it leaves a zombie in the process tree:
| root 29065 0.0 0.0 0 0 ? Z 11:40 0:00 [mss_snort-updat <defunct>]
That zombie is there waiting for you to wait for it. That is, it
will disappear once you have received its exit status with wait()
| This is probably all moot as the processors are python based and in
| the future I'll just create a thread for each one that is spawned
| instead of a seperate process. However I'd like to understand why
| this is going on.
A separate process fork may still be a better deal than a thread.
That's up to you, just wanted to point out that processes aren't
good only for exec(). If you fork the interpreter, remember to
exit and never return to the caller (including through an exception.)
More information about the Python-list