Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: How to get PID in backgrounded /bin/sh while loop? Message-ID: <7486@jpl-devvax.JPL.NASA.GOV> Date: 20 Mar 90 21:11:29 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 27 In article montanaro@crdgw1.ge.com (Skip Montanaro) writes: : : Given the small shell script: : : #!/bin/sh : : ... do some stuff ... : : 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), : but that is overkill for the situation I have at hand. I've tried various : combinations of quoting $$, evaling things containing it, and so on, but : nothing yields helpful results. $! is undefined within the loop. How 'bout pid=`perl -e 'print getppid;'` Larry Wall lwall@jpl-devvax.jpl.nasa.gov