Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91679

Re: Best way to prevent zombie processes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Best way to prevent zombie processes
Date Mon, 1 Jun 2015 14:59:30 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 38
Message-ID <mkhs0i$9d5$2@reader1.panix.com> (permalink)
References <87vbf8l9e7.fsf@Equus.decebal.nl> <87vbf88k0n.fsf@elektro.pacujo.net>
NNTP-Posting-Host 67-130-15-94.dia.static.qwest.net
X-Trace reader1.panix.com 1433170770 9637 67.130.15.94 (1 Jun 2015 14:59:30 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Mon, 1 Jun 2015 14:59:30 +0000 (UTC)
User-Agent slrn/1.0.1 (Linux)
Xref csiph.com comp.lang.python:91679

Show key headers only | View raw


On 2015-05-31, Marko Rauhamaa <marko@pacujo.net> wrote:
> Cecil Westerhof <Cecil@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            

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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