Best way to prevent zombie processes

Marko Rauhamaa marko at pacujo.net
Mon Jun 1 06:21:43 EDT 2015


Chris Angelico <rosuav at gmail.com>:

> On Mon, Jun 1, 2015 at 7:20 PM, Cecil Westerhof <Cecil at decebal.nl> wrote:
>> But
>> what if I want for certain Popen signals SIG_IGN and others SIG_DFL.
>> How should I do that?
>
> You can't. A signal is a signal; you can't specify default handling
> for some and not others. The only way is to actually handle them, and
> then you can decide what to do on a per-process basis.

Signals are a very crude, old-school UNIX system programming concept.

One of their worst problems is their global scope. You can't
compartmentalize signals through ordinary means of encapsulation
(libraries, classes).

Linux is addressing this particular issue "as we speak:"

   This patch series introduces a new clone flag, CLONE_FD, which lets
   the caller handle child process exit notification via a file
   descriptor rather than SIGCHLD.

   <URL: https://lwn.net/Articles/636646/>

I guess it will be a while before this facility will be available to
Python programmers. For example, signalfd and eventfd were introduced in
2007 and 2010, respectively, but still aren't supported by Python.


Marko



More information about the Python-list mailing list