Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!att!cbnewsm!lfd From: lfd@cbnewsm.att.com (leland.f.derbenwick) Newsgroups: comp.unix.wizards Subject: Re: forking and zombies in SYSV. Summary: signal(SIGCHLD, SIG_IGN) _is_ in the SVID. Message-ID: <1990Aug27.170458.20643@cbnewsm.att.com> Date: 27 Aug 90 17:04:58 GMT References: <1990Aug20.133107.12516@lth.se> <5980067@hpfcdc.HP.COM> Organization: AT&T Bell Laboratories Lines: 41 In article <5980067@hpfcdc.HP.COM>, rml@hpfcdc.HP.COM (Bob Lenk) writes: > Several people have suggested > > signal(SIGCLD, SIG_IGN); > > While this does prevent zombies from being formed in System III, System > V, and compatible systems, there are some reasons to avoid it: > > 1) Portability. This does not work in all implementations > (notably not in BSD). It is not required by POSIX, XPG, > or even the SVID. This behavior _is_ required by the SVID: see "signal(BA_OS)" on page 6-124 of Volume 1 of the Third Edition (8/89): If the diposition for SIGCHLD is set to SIG_IGN, the calling process's child processes will not create zombie processes when they terminate [see exit(BA_OS)]. If the calling process subsequently waits for its children, it will block until all of its children terminate; it will then return a value of -1 with errno set to ECHILD ... > 2) Possible side-effects. This can impact any part of your > program that creates children, including library calls that > might create children for reasons unknown to you. It can > impact the programs exec'd by descendents if they create > children. Most code that creates children expects to wait > for them. This can cause such code to hang (until all your > children have died) and/or to get unexpected errors (possibly > missing out on important status information). This is correct, but it would be simple to add signal(SIGCHLD, SIG_DFL); to the child processes (in main() if they are invoked via "system", or just after the fork() if the fork()/exec() is done explicitly). -- Speaking strictly for myself, -- Lee Derbenwick, AT&T Bell Laboratories, Warren, NJ -- lfd@cbnewsm.ATT.COM or !att!cbnewsm!lfd