How to get PID in backgrounded /bin/sh while loop?
Skip Montanaro
montnaro at spyder.crd.ge.com
Wed Mar 21 00:45:31 AEST 1990
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.
--
Skip (montanaro at crdgw1.ge.com)
More information about the Comp.unix.questions
mailing list