On 8/26/06, George Boudreau <georgeb linuxfromscratch.org> wrote:
>
> .. I still have no method for making progress_bar run
without fuser.
> Ideas anyone???
George, I think I finally figured out a way to do this. I'm
a little
short on time, so I'll try to explain. No time for diff's
but you
should be able to figure it out.
>From inside the script, I tried using $PPID, but it was
coming out to
strange values. I also ran ps with a lot of args, and found
that
sometimes the script parent was even pid 1. Seems there's
an extra
level of parenting or 2 when make actually runs a shell
command.
Then I found out that within the Makefile, each target
command has a
PPID of the actual make process. Try this.
fud:
echo PPID=$$PPID
It will echo the PID of make itself. So, the answer to the
problem is
to use $$PPID in the Makefile and pass it as an argument to
progress_bar.sh. Here's a simple example that I found to
work.
$ cat Makefile
foo:
echo -n "Building $ "
./script.sh $ $$PPID &
sleep 2
touch $
echo
bar:
echo -n "Building $ "
./script.sh $ $$PPID &
sleep 2
touch $
echo
all: foo bar
clean:
rm -f foo bar
$ cat script.sh
#!/bin/bash
TARGET=$
MAKE_PPID=$
until [[ -f $ ]] || [[ ! -e /proc/$ ]];
do
echo -n '.'
sleep .12
done
$ make all
Building foo.................
Building bar................
It works when I interrupted the process, too. What do you
think?
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discu
ss
FAQ: http://www.linux
fromscratch.org/faq/
Unsubscribe: See the above information page
|