Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!news.panservice.it!feed.xsnews.nl!border01.ams.xsnews.nl!feeder04.ams.xsnews.nl!abp002.ams.xsnews.nl!frontend-F09-12.ams.news.kpn.nl From: Cecil Westerhof Newsgroups: comp.lang.python Subject: Best way to prevent zombie processes Organization: Decebal Computing X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ Date: Sun, 31 May 2015 23:33:36 +0200 Message-ID: <87vbf8l9e7.fsf@Equus.decebal.nl> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:2/WGkLfCE/w+d+OVVB10dJkqGRM= MIME-Version: 1.0 Content-Type: text/plain Lines: 20 NNTP-Posting-Host: 81.207.62.244 X-Trace: 1433108757 news.kpn.nl 18620 81.207.62.244@kpn/81.207.62.244:57330 Xref: csiph.com comp.lang.python:91596 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