Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ukma!tut.cis.ohio-state.edu!osu-cis!att!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.questions Subject: Re: Getting rid of a process Message-ID: <7702@chinet.chi.il.us> Date: 13 Feb 89 05:10:36 GMT References: <102@avatar.UUCP> <27866@bu-cs.BU.EDU> Reply-To: les@chinet.chi.il.us (Leslie Mikesell) Distribution: usa Organization: Chinet - Public Access Unix Lines: 27 In article <27866@bu-cs.BU.EDU> madd@bu-it.bu.edu (Jim Frost) writes: >In article <102@avatar.UUCP> kory@avatar.UUCP (Kory Hamzeh) writes: >|The main process (the parent which does all of the forks) can not >|do a wait() because I can't get blocked for anything. >What I usually do is: > fireman() /* catches falling children */ > { union wait wstatus; > while (wait3(&wstatus, WNOHANG, NULL) >= 0) > ; > } > main() > { > signal(SIGCHLD, fireman); > /*...*/ > } SysV only has wait(), and signals are not queued or deferred inside the handlers. However, SIGCHLD is a little different (otherwise init would not work). If a defunct process exists when the signal(SIGCHLD,...) call is made, the signal happens immediately. Putting a signal(SIGCHLD,fireman) as the last statement in the fireman() function will give the effect of queued signals. Les Mikesell