Quote:
Originally Posted by zx712
I tried this:
P1 &
pid1=$! #this is id of the first process
While( the status of pid1 is not zero) #how do I get the status of pid1?
do
run p2
done
|
Provided you only have P1 in the background, you don't need the process number;
jobs will list the background processes for you.
Code:
P1 &
while jobs | grep -cq .; do
P2
done
There are two differences between this and my previous post:
- This won't kill P2 when P1 exits; my one-liner will
- This won't allow P1 foreground access to the terminal; my one-liner will
Either can easily be made into a daemon script. Neither allow for P1 to be started independently of the script, though.
Kevin Barry
PS One-line version of this one is straightforward:
Code:
P1 & while jobs | grep -cq .; do P2; done