On 2015-05-31, Marko Rauhamaa <ma...@pacujo.net> wrote: > Cecil Westerhof <ce...@decebal.nl>: > >> 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? > > If you don't care to know when child processes exit, you can simply > ignore the SIGCHLD signal: > > import signal > signal.signal(signal.SIGCHLD, signal.SIG_IGN) > > That will prevent zombies from appearing.
Bravo! I've been writing Unix apps for 30 years, and I did not know that. Is this something recent[1], or have I somehow managed to avoid this useful bit of info for that long? [1] "Recent" of course being rather subjective and highly age-dependent. -- Grant Edwards grant.b.edwards Yow! How's it going in at those MODULAR LOVE UNITS?? gmail.com -- https://mail.python.org/mailman/listinfo/python-list