How to get PID in backgrounded /bin/sh while loop?
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Wed Mar 21 07:11:29 AEST 1990
In article <MONTNARO.90Mar20094531 at spyder.crd.ge.com> montanaro at 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 at jpl-devvax.jpl.nasa.gov
More information about the Comp.unix.questions
mailing list