In C you would set a timer and a signal handler, I don't think you can do that nicely in a shell script.
If you never wanted the script to run for more than 120 seconds you could put something in the background like ( sleep 120; kill $$ )&, but you couldn't reset that timer and it would hang around even if the script terminated.
I tried some tests with the alarm function, but couldn't get it to work as advertised. I need to dig out my KSH book to read it but I found a posting from David Korn on a forum elsewhere. His recollection of how it worked didn't pan out for me.
Also, I wouldn't even bother trying to use it in a ksh clone, get the real ksh from David's website.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.