Op Monday 1 Jun 2015 03:03 CEST schreef Cameron Simpson: > On 31May2015 23:33, Cecil Westerhof <ce...@decebal.nl> wrote: >> 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? > > The standard trick is to make the process a grandchild instead of a > child. Fork, kick off subprocess, exit (the forked child). > > But provided you will collect the children eventually then zombies > are only untidy, not very resource wasteful. They are essentially > just slots in the process table left around so that exit status can > be collected; the resources associated with the full process > (memory, open file, etc) have already been freed.
I do not like untidy. ;-) But Marko already gave the solution: import signal signal.signal(signal.SIGCHLD, signal.SIG_IGN) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list