Grant Edwards <invalid@invalid.invalid>: > On 2015-05-31, Marko Rauhamaa <ma...@pacujo.net> wrote: >> 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?
I wasn't aware of it ever having been any other way. However: POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see wait(2)). Nevertheless, the historical BSD and System V behaviors for ignoring SIGCHLD differ, so that the only completely portable method of ensuring that terminated children do not become zombies is to catch the SIGCHLD signal and perform a wait(2) or similar. <URL: http://man7.org/linux/man-pages/man2/sigaction.2.html> If you possess the Stevens book, you'd probably find out how SIGC(H)LD was treated in BSD and System V. I can't remember despite programming for either environment. Marko -- https://mail.python.org/mailman/listinfo/python-list