Well the thing is that the kill -9 command does not work, I tried it... once the processes are written with the "defunct" mention next to them they are unkillable because they don't really exist any more i think....

Theses processes were created with the thread module, but they should end, there is no infinit loops in them, and they don't seem to take computing time either, so it looks as if they are not running.

Well in fact it is a little more complicated, I start a thread and in the thread i use an os.spawnv (this does an automatic fork I think?) to start another script, and it is that script that zombifies. (Should there be a return None at the end of all functions? because i tried to put a sys.exit() to be sure it exited but it still stays there as a zombi, so i'm thinking that the parent process -the thread- has to clean up by its self...)

My understanding of sys.exit is that if called in the main thread it will kill all the other threads, but if called in a child thread it will only kill off that thread. I may be wrong though. I don't know if that is related to the problem you are having.

Some more questions:

* are the spawned programs also written in Python?

* is there any way to debug them, e.g. by putting in trace statements so that you can see what they are blocking on?

I did a few experiments and I think you have two options:
1. Only spawn the child processes in the main thread (why do you need to spawn them in a child thread, perhaps you only need threads for monitoring if at all?). This will allow the child processes to respond to the os.kill.

2. If you must use threads then you need to signal the child process program to terminate somehow and then os.wait() for the child process to finish. But os.kill is ignored! Perhaps you can signal the child app using sockets or pipes.