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


Groups > comp.lang.python > #32591

Re: Avoiding defunct processes

References <b8d1fb3a-20cd-4889-900a-61ec5b64f0c1@uc4g2000pbc.googlegroups.com>
Date 2012-11-02 13:36 +1100
Subject Re: Avoiding defunct processes
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3175.1351823803.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Nov 2, 2012 at 1:16 PM, Richard <richardbp@gmail.com> wrote:
> Hello,
>
> I create child processes with subprocess.Popen().
> Then I either wait for them to finish or kill them.
> Either way these processes end up as defunct until the parent process
> completes:
> $ ps e
> 6851 pts/5    Z+     1:29 [python] <defunct>
>
> This confuses another library as to whether the processes are
> complete.
> For now I detect which processes are defunct by parsing the output of
> "ps".
> What would you recommend? I am hoping there is a cleaner way.

That's a zombie process, it's finished but the parent hasn't wait()ed
for it yet.

http://docs.python.org/3.3/library/subprocess.html#subprocess.Popen.wait

Once the process has ended, call that to get its return value and
clean everything up.

ChrisA

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


Thread

Avoiding defunct processes Richard <richardbp@gmail.com> - 2012-11-01 19:16 -0700
  Re: Avoiding defunct processes Chris Angelico <rosuav@gmail.com> - 2012-11-02 13:36 +1100
  Re: Avoiding defunct processes Nobody <nobody@nowhere.com> - 2012-11-02 15:46 +0000

csiph-web