[UFO Chicago] Shell scripting, timeouts
Ian Bicking
ianb@colorstudy.com
Thu, 13 Feb 2003 13:01:28 -0600
There's this unreliable program (wvware) that is being run on a server
I'm using. Sometimes it goes into an infinite loop and takes up lots
of CPU while it's just sitting there.
How might I set up a timeout for it? I'd like to make a shell-script
wrapper that kills the program if it takes too long. I could do:
#!/bin/sh
wvware $* &
PID=$!
sleep 2
kill -9 $PID
But that's kind of lame. The program won't return as fast as it
usually can, if IO is done through stdin/stdout it would get all messed
up, etc. Is there an easier/better way?
Ian