The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 06-06-2008
itsme_maverick itsme_maverick is offline
Registered User
  
 

Join Date: May 2008
Posts: 5
Quote:
Originally Posted by fabtagon View Post
simple polling approach (this master script itself may not run parallel, vulnerable to symlink attacks through unsafe tmp file creation, ...)

Code:
#!/bin/bash
# should work in most shells
(script1; echo $? > /tmp/retval1 ) &
script2
# both do now run in parallel
# ...
# well, after some time script2 will have finished, so well have to check whether 2 also has
retval2=$?
while [ $? -eq 0 ]
do
  sleep 1s
  pidof script1 > /dev/null
done
retval1=`cat /tmp/retval1`
if [ something about retval1 and retval2 ]
then
  script3
fi

What does the line in "while loop" do ? pidof script1 > /dev/null