Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: How to get PID in backgrounded /bin/sh while loop? Message-ID: <6055@star.cs.vu.nl> Date: 20 Mar 90 22:12:20 GMT References: Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, the Netherlands Lines: 37 In article , montnaro@spyder.crd.ge.com (Skip Montanaro) writes: )... ) while true ; do ) ) ... do some loopy stuff ... ) ) done & ) )how do you discover the process id of the backgrounded while loop process? ) )A colleague suggested I write a small C program that just calls getppid(2), )... You could place such a utility in, say, /usr/local/bin for the time being. I don't know what POSIX has to say about it, but somehow the child's pid ought to be easily determined. Instead of mypid=`getppid` ...I'd rather see something like mypid=$% Nowadays the only alternative to the C program is: sh -c ' pid=$$ while : do # some loopy stuff with $pid done ' & -- 1) Will 4.5BSD have wait5()? |Maarten Litmaath @ VU Amsterdam: 2) Sleep(3) should be sleep(2) again.|maart@cs.vu.nl, uunet!mcsun!botter!maart