LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] real time shell question...

[ILUG] real time shell question...

Justin Mason jm at netnoteinc.com
Thu Apr 5 15:18:55 IST 2001


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.




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell