Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bcstec!ruben From: ruben@bcstec.boeing.com (Reuben Wachtfogel) Newsgroups: comp.unix.questions Subject: Re: How can a child detect the death of its parent Summary: Maybe ... Message-ID: <931@bcstec.boeing.com> Date: 7 Jun 91 20:01:58 GMT References: <298@wimpy.nms.gdc.portal.com> Organization: Boeing Computer Services, Seattle Lines: 30 In article <298@wimpy.nms.gdc.portal.com>, bergquis@nms.gdc.portal.com (Brett Bergquist) writes: > I have an application with forks a tightly coupled child process to handle > communications functions. The child communicates to the parent through > a pipe. > > I know how to detect the death of the child process using SIGCLD in the parent, > but how can I detect the death of the parent process in the child? > The parent could be set up to signal the child upon most non-violent terminations with kill (e.g. use signal to trap termination faults) Additionally the child could poll for the existence of the parent. signal(SIGALRM, check_for_parent); alarm(TEN_SECONDS); where check_for_parent checks for getppid()==1 which means that the parent is gone and the child has been adopted by the init (UID=1) process. I doubt this is very robust though, especially in cases where the parent has zombied out, and I'll be checking here for a better answer. ---------------------------------------------------------------------- I have used something like this on APOLLO and it seems to work but ... P.S. My recent posting containing site-specific article numbers was intended to inspire people to REALLY read the FAQs. Thanx to the many (!!) letters noting my goof. Please no more.