Re: Make set_time_limit() timeout a catchable fatal error
| From: | David Muir | Date: | Wed, 09 Mar 2011 01:30:49 +0000 |
| Subject: | Re: Make set_time_limit() timeout a catchable fatal error | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51629@lists.php.net to get a copy of this message | ||
Although it doesn't let you recover from a timeout, you could use
register_shutdown_function to gracefully exit after a fatal error.
register_shutdown_function(function(){
$error = error_get_last();
if($error && $error['type'] === E_ERROR){
echo 'PHAIL! Oh noes, something went wrong!';
// do whatever else you need to do before quitting
}
});
Cheers,
David
On 08/03/11 22:39, Pierre Joye wrote:
> hi,
>
> is not the goal of this setting to prevent that a script runs longer
> than a given time? A catchable error will prevent that to happen.
>
> On Tue, Mar 8, 2011 at 2:05 PM, Sebastian Bergmann <sebastian@php.net> wrote:
>> Could set_time_limit() be changed in such a way that it triggers a
>> catchable fatal error instead of a fatal error? Thanks!
>>
>> --
>> Sebastian Bergmann Co-Founder and Principal Consultant
>> http://sebastian-bergmann.de/
>> http://thePHP.cc/
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>