title: Zombie process in python multiprocessing daemon
body: <p>After researching python daemons, this walk through seemed to be the most robust: <a href="http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/" rel="nofollow">http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/</a></p>
  
  <p>Now I am trying to implement a pool of workers inside the daemon class which I believe is working (I have not thoroughly tested the code) except that on the close I get a zombie process. I have read I need to wait for the return code from the child but I just cannot see exactly how I need to do this yet.</p>
  
  <p>Here are some code snippets:</p>
  
  <pre><code>def stop(self):
      ...
      try:
          while 1:
              self.pool.close()
              self.pool.join()
              os.kill(pid, SIGTERM)
              time.sleep(0.1)
      ...
  </code></pre>
  
  <p>Here I have tried <code>os.killpg</code> and a number of <code>os.wait</code> methods but with no improvement. I also have played with <code>closing</code>/<code>joining</code> the pool before and after the <code>os.kill</code>. This loop as it stands, never ends and as soon as it hits the <code>os.kill</code> I get a zombie process. <code>self.pool = Pool(processes=4)</code> occurs in the <code>__init__</code> section of the daemon. From the <code>run(self)</code> which is excecuted after <code>start(self)</code>, I will call <code>self.pool.apply_async(self.runCmd, [cmd, 10], callback=self.logOutput)</code>. However, I wanted to address this zombie process before looking into that.</p>
  
  <p>How can I properly implement the pool inside the daemon to avoid this zombie process?</p>