Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ccice5.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rochester!ritcv!ccice5!ahb From: ahb@ccice5.UUCP (Al Brumm) Newsgroups: net.unix-wizards,net.unix Subject: Re: UNIX question Message-ID: <974@ccice5.UUCP> Date: Wed, 11-Dec-85 18:49:00 EST Article-I.D.: ccice5.974 Posted: Wed Dec 11 18:49:00 1985 Date-Received: Fri, 13-Dec-85 20:34:30 EST References: <156@uw-june> Reply-To: ahb@ccice5.UUCP (Al Brumm) Organization: CCI, Central Engineering, Rochester, NY Lines: 49 Keywords: zombies Xref: watmath net.unix-wizards:16083 net.unix:6618 In article <156@uw-june> pjs@uw-june (Philip J. Schneider) writes: >My question: Is there any way to kill off these zombies so I can get > more processes ? Or, failing that, is there any other > way to do what I want ? A clean way to handle this problem on Sys3 was to use the following system call in the parent process: signal(SIGCLD, SIG_IGN); Then when a child process exited, a zombie would not be created. Note that this would not allow you to examine the child's exit status. However, you could examine the exit status by doing the following: int sigcld() { int pid, status; pid = wait(&status); . . (do stuff) . } main() { int (*sigcld)(); signal(SIGCLD, sigcld); } The example immediately above is also possible in 4.2BSD, only SIGCLD is called SIGCHLD. Then again, there is always the double fork() trick which goes something like this: if (fork()) { /* parent */ wait((int *)0); /* no zombies please */ } else { if (fork()) { /* child */ exit(0); /* satisfy parent's wait */ } else { /* grandchild */ do_stuff(); /* since my parent exit'ed */ . /* I am inherited by init */ . . } } The above trick is used quite heavily by the UNET servers.