Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do variable interfere with background processing??

Status
Not open for further replies.

shaokat

Technical User
Oct 8, 2002
11
IN
I have this loop:
for transpart in a b c d
do
while read jpegimage pageseg
do
dest=$psegdir/$pageseg
if [ -f $extract/$jpegimage ] ; then
echo ConvertImages... converting $jpegimage

cat $extract/$jpegimage |jpegtopnm |pnmscale -xysize 2100 1680 |pgmtopbm -floyd |ppmtobmp -windows >$itmp/tempimg$transpart.bmp
mv $extract/$jpegimage $jpgtrash

~/gbm/gbmbpp -m bw $itmp/tempimg$transpart.bmp,inv $itmp/tempimg$transpart.pseg,pelx=6000,pely=6000
mv $itmp/tempimg.pseg $dest
else
print "$extract/$jpegimage $dest" >> ${filename}$transpart.missing
fi
done <${filename}trans.$transpart &
done
wait

Note that the inner while do ... done loop has '&' at the end indicating a background process.
The question: Will the variables interfere with each other as the four background processes run?

 
Someone please correct me if I am wrong.

Whatever you define outside of the loop or in the big loop will be effective in the inner loop. But if there is a new definition in the inner loop, the variable will be updated.

I am not sure, but I do not think background or not will make a difference. But session (like when you login or when you submit a script job) does. What I am saying is a background process does not create an independent session.
 
Since the inner loop use redirection, I think it is executed in a subshell.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top