Date: 01/28/99
- Next message: Thies C. Arntzen: "Re: [PHP-DEV] CVS update: php3"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3"
- In reply to: Rasmus Lerdorf: "[PHP-DEV] Interesting sleep() side-effect"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
It's fine actually. Our timer times actual CPU time, not real time. sleep() does not consume any CPU time, so the script will not timeout for quite a while. This is actually quite intentional...
Zeev
At 00:49 27/01/99 -0500, Rasmus Lerdorf wrote:
>In testing Thies' connection abort detection code, completely unrelated to
>his stuff, I noticed an interesting side-effect of calling sleep() in a
>PHP script. I have tried this on both Linux and Solaris and get the same
>results. Could you guys with access to other OS'es try this one?
>
><?
> set_time_limit(5);
> register_shutdown_function("done");
> function done() {
> global $i;
>
> $fp = fopen("/tmp/done","w");
> fputs($fp,"i reached $i\n");
> fclose($fp);
> }
>
> for($i=0; $i<30000; $i++) {
> for($j=0;$j<1000;$j++) $a=sqrt($j);
> /* sleep(1); */
> echo "$i ................................................................................<br>";
> flush();
> }
>?>
>
>
>This script should run for 5 seconds, unless of course you are on a
>massively fast machine that can do 30000 sqrt()'s in 5 seconds. However,
>when you uncomment the sleep(1) call there, it will happily run way past 5
>seconds. Looks to me like the sleep() system call is interfering with our
>itimer. The man pages state that sleep() may be implemented as a SIGALRM,
>but we are using a SIGPROF itimer, so I thought we were actually safe
>here.
>
>It doesn't worry me too much. It is more an interesting side effect, but
>something we might want to document as a caveat in the sleep()
>documentation. I would be intersted in hearing if this behaviour is
>consistent across all the operating systems.
>
>The "/tmp/done" file is not related to this particular message. That's
>just how I am testing to see if PHP catches when the client closes the
>socket.
>
>-Rasmus
>
>
>--
>PHP Development Mailing List http://www.php.net/
>To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
>For help: php-dev-help <email protected>
>
>
>
-- Zeev Suraski <zeev <email protected>> http://www.zend.com/ For a PGP public key, finger bourbon <email protected>-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: Thies C. Arntzen: "Re: [PHP-DEV] CVS update: php3"
- Previous message: rasmus: "[PHP-DEV] CVS update: php3"
- In reply to: Rasmus Lerdorf: "[PHP-DEV] Interesting sleep() side-effect"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

