ya, i had this problem too - there's a php timeout function, but it doesn't work well, and not at all with exec() calls (from what i've read). PHP's not too good with setting the maximum script length.
what i did was, wrote a perl script, with an exec{
code
};
block, and used one of the perl packages that throws an exception after a certain period of time - then after the eval loop, check the value of @_, and see if the error was thrown. 'dont have the script in front of me, but i pretty much copied the syntax outta the "perl cookbook". i then printed the results, which php would interpret - perl would return whether or not it timed out, etc...
anyway, i know this is vague, but hopefully it'll help - have php call a perl script which calls the other php script with a timeout - i know it's a runaround
good luck,
blake