Path: utzoo!attcan!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!bohra!als From: als@bohra.cpg.oz (Anthony Shipman) Newsgroups: comp.unix.questions Subject: Re: How do you handle while(1) fork(); ? Summary: set up a barrier Message-ID: <416@bohra.cpg.oz> Date: 17 Jul 90 09:37:35 GMT References: <841@massey.ac.nz> <1990Jul11.115612.2155@aucs.uucp> <4261@uqcspe.cs.uq.oz.au> Organization: Computer Power Group, Melb, Australia Lines: 25 In article <4261@uqcspe.cs.uq.oz.au>, rhys@batserver.cs.uq.oz.au (Rhys Weatherley) writes: > I would also be interested in a summary, but how about this one: > > while (!fork ()) > { > /* some non-important code */ > } > /* some "clean-up" code */ > exit (0); > > This will create a round-robin of processes, where each process spawns > a child, and then dies (fork() returns 0 in the child process). Extremely > difficult to kill these ones, because by the time you have a process-id > to kill, that process doesn't exist usually anymore! This is an I had this problem once. I used a little program that did a kill -9 on a pid that was ahead of the pid sequence from the runaway program. The kill -9 was put into an infinite loop. There was a good chance that the kill would get the process when its pid got big enough. (There was also some chance that an innocent process would be killed, but not much). -- Anthony Shipman ACSnet: als@bohra.cpg.oz.au Computer Power Group 9th Flr, 616 St. Kilda Rd., St. Kilda, Melbourne, Australia D