Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91643
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Best way to prevent zombie processes |
| Organization | Decebal Computing |
| References | <87vbf8l9e7.fsf@Equus.decebal.nl> <mailman.258.1433125553.5151.python-list@python.org> |
| Date | 2015-06-01 11:23 +0200 |
| Message-ID | <87iob7lr37.fsf@Equus.decebal.nl> (permalink) |
Op Monday 1 Jun 2015 03:03 CEST schreef Cameron Simpson:
> On 31May2015 23:33, Cecil Westerhof <Cecil@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 23:33 +0200
Re: Best way to prevent zombie processes Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 01:22 +0300
Re: Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:20 +0200
Re: Best way to prevent zombie processes Chris Angelico <rosuav@gmail.com> - 2015-06-01 20:04 +1000
Re: Best way to prevent zombie processes Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 13:21 +0300
Re: Best way to prevent zombie processes Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 13:25 +0300
Re: Best way to prevent zombie processes Grant Edwards <invalid@invalid.invalid> - 2015-06-01 14:59 +0000
Re: Best way to prevent zombie processes Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 18:39 +0300
Re: Best way to prevent zombie processes Cameron Simpson <cs@zip.com.au> - 2015-06-01 11:03 +1000
Re: Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:23 +0200
Re: Best way to prevent zombie processes Ben Finney <ben+python@benfinney.id.au> - 2015-06-01 13:37 +1000
Re: Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 14:16 +0200
Re: Best way to prevent zombie processes Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 16:32 +0300
Re: Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 16:37 +0200
Re: Best way to prevent zombie processes Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 15:03 +0200
csiph-web