Xref: utzoo comp.unix.questions:11678 comp.unix.wizards:14669 comp.unix.xenix:4942 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!rutgers!att!ihlpb!gregg From: gregg@ihlpb.ATT.COM (Wonderly) Newsgroups: comp.unix.questions,comp.unix.wizards,comp.unix.xenix Subject: Re: Getting rid of a process Message-ID: <9567@ihlpb.ATT.COM> Date: 13 Feb 89 15:51:50 GMT References: <102@avatar.UUCP> Distribution: usa Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 72 From article <102@avatar.UUCP>, by kory@avatar.UUCP (Kory Hamzeh): > I have written an application which forks and execs off many subtasks. > The main process (the parent which does all of the forks) can not > do a wait() because I can't get blocked for anything. Well, this results > in a lot of "" processes in the process table when the child > exits. > > Is there any way to get rid of these processes? If not, will they take > up any core space? I assume they will take up a slot in the process table. If you have SIGCLD, you have two choices. If you absolutly do not wish to know anything about the children than just use signal (SIGCLD, SIG_IGN); to tell the kernel to implicilty wait on them for you. When they die, they will be removed... If you wish to know something, then use something like routine () { int status, pid; while ((pid = wait (&status)) == -1 && errno == EINTR) continue; if (status) printf ("Process %d died with status 0x%04x\n", pid, status); } main (...) { ... signal (SIGCLD , routine); ... } to look at the return status and catch possible problems. I would suggest that you do check return status because subtle problems can go unnoticed if you do not. If you do not have SIGCLD, use junk() {} main() { ... try_wait(); ... } try_wait() { int amt, status, pid, (*ftn)(); amt = alarm (0); ftn = signal (SIGLARM, junk); (void) alarm (1); pid = wait (&status); (void) alarm (0); (void) signal (SIGALRM, ftn); (void) alarm (amt); if (pid != -1 && status) printf ("Process %d died with status 0x%04x\n", pid, status); ... } -- Gregg Wonderly DOMAIN: gregg@ihlpb.att.com AT&T Bell Laboratories UUCP: att!ihlpb!gregg