Best way to prevent zombie processes

Cecil Westerhof Cecil at decebal.nl
Sun May 31 17:33:36 EDT 2015


At the moment I have the following code:
    os.chdir(directory)
    for document in documents:
        subprocess.Popen(['evince', document])

With this I can open several documents at once. But there is no way to
know when those documents are going to be closed. This could/will lead
to zombie processes. (I run it on Linux.) What is the best solution to
circumvent this?

I was thinking about putting all Popen instances in a list. And then
every five minutes walk through the list and check with poll if the
process has terminated. If it has it can be released from the list.
Of-course I need to synchronise those events. Is that a good way to do
it?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list