Paul J Collins said:
> If you have job control, you could write a script that backgrounds it,
> sleeps for 20 seconds and then does kill %+, which should kill the
> last-spawned job. Plain Bourne shell doesn't have job control
> however.
no, that should work. You can run stuff with &, you just can't fg
it again or use the %- %+ stuff. So this should work:
for test in `foo -h | awk '{print $1}'`
do
foo $test &
foopid=$!
secs=0
while [ $secs -lt 20 ] ; do
if kill -0 $foopid ; then
sleep 1
else
echo "foo has finished" 1>&2; break
fi
done
if kill -0 $foopid ; then
echo "foo has timed out, killing it" 1>&2
kill -15 $foopid
fi
wait $foopid # to get the exit status
done
Something like that anyway ;)
--j.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!