Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51631 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92260 invoked from network); 9 Mar 2011 14:18:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2011 14:18:45 -0000 Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:42096] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/E0-21312-44C877D4 for ; Wed, 09 Mar 2011 09:18:44 -0500 Received: by vws10 with SMTP id 10so488455vws.29 for ; Wed, 09 Mar 2011 06:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=k8iKUTA3tqeWe8ebqxOzRCCiXyCUd+MQ07xkDxHWE08=; b=JiN+3o54cOamh71jirg6zlRmZ3ydcTEtFm9erwPHzSdXuBa7q7WkvX7a6fOpo4/eBk GkgPXunK8seBeSHfUUvuDs1QwipkQ6Rz0DgI7GSy93IfvI3mbIRs36ous0OmSdHFCRwn UFG+qMuqcBxN+ZeECvG4RbTQloLLKgdJZc/d8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=QwgkJ9vpCyf8RmHt2Z6oDejAQZBP1A/zHhb7AGGnN2KqicHzWGBV/A0sTjlpd16FVe 8LRQ77wOrLgntF6UBxcNy61Fm3mIFoGBCy0sE0e4LEjok/QenlUvCvMsFhH51DlIFxag bQEZ96nXfsEhkEv6Wr8XBcA3K28inwZMJ6Rqc= MIME-Version: 1.0 Received: by 10.52.66.163 with SMTP id g3mr9603344vdt.94.1299680321834; Wed, 09 Mar 2011 06:18:41 -0800 (PST) Received: by 10.220.125.67 with HTTP; Wed, 9 Mar 2011 06:18:41 -0800 (PST) In-Reply-To: References: <4D7629B5.4090007@php.net> <4D76D849.6000103@gmail.com> Date: Wed, 9 Mar 2011 11:18:41 -0300 Message-ID: To: Hannes Landeholm Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf307f3ba6e791fe049e0d67da Subject: Re: [PHP-DEV] Make set_time_limit() timeout a catchable fatal error From: martinscotta@gmail.com (Martin Scotta) --20cf307f3ba6e791fe049e0d67da Content-Type: text/plain; charset=ISO-8859-1 Fatal error are most dumb feature in the language. The are lot of "blind" areas where you don't know if you will ever return... include "file.php"; new Class(); call_func(); All fatal errors should be changed to "catchable fatal errors" so applications will be able to recover themselves... and if they don't catch the error... then die. it would be nice if all errors could be changed into exceptions. Martin Scotta On Wed, Mar 9, 2011 at 10:56 AM, Hannes Landeholm wrote: > I second making time limit reached catchable. All non catchable fatal > errors > are a problem for me. I need to handle problems gracefully to ensure the > stability of production systems instead of PHP just killing itself without > warning. I just reported a similar issue: > http://bugs.php.net/bug.php?id=54195 > > A simple way to implement this would be to register a function that would > be > called N seconds before the script would timeout. > > register_timeout_handler(2, function() { die("PHP timed out."); }); > > It would be called just as a shutdown function - in fact I'd like to use > the > same function as my shutdown function and get the error with > error_get_last(). Of course set_time_limit(0) could be used in this > function > to prevent the timeout of the timeout handler. This does not "prevent" > timeout since set_time_limit could have been called by the script before > the > timeout anyway. > > On that note I also miss a function which returns the time the script can > keep running for. If that calculate needs to be calculated to implemented > to > implement this, why not make the value available to the PHP script? > > ~Hannes > > On 9 March 2011 02:30, David Muir wrote: > > > 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 > > 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 > > >> > > >> > > > > > > > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --20cf307f3ba6e791fe049e0d67da--