Date: 01/27/99
- Next message: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Previous message: timothy: "[PHP-DEV] CVS update: php3"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Dave Walton: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Maybe reply: Tom May: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Zeev Suraski: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Next message: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Previous message: timothy: "[PHP-DEV] CVS update: php3"
- Next in thread: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Rasmus Lerdorf: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Dave Walton: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Maybe reply: Tom May: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Reply: Zeev Suraski: "Re: [PHP-DEV] Interesting sleep() side-effect"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

