recursion too deep

I am running a korn shell script which has a recursive function.
The script ran for 117 iterations and ended up with the following error
"recursion too deep".
what should be done to avert this?
Thanks in advance
Swamy
p.s. I am on UNIX MPRAS V4

check your 'end of recursion' condition - you maybe running into the 'infinite' recursion.

This shell script checks for existence of a file.

psuedo code
-------------------------------------------------
function chk_for_file

if(file)
then do some thing
exit
else sleep for some time and call chk_for_file again
-------------------------------------------------
Thanks
Swamy

Why are you recursing?

There is absolutely no need to do so, and if the file never exists you are indeed in an infinte loop.


function chk_for_file
{
while [[ ! -f file ]] ; do
     sleep <some number of seconds>
done

<do whatever>
}