#29474 [Csd]: Function usleep doesn't work under Windows.
| From: | wez@php.net | Date: | Sun, 01 Aug 2004 00:39:49 +0000 |
| Subject: | #29474 [Csd]: Function usleep doesn't work under Windows. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63866@lists.php.net to get a copy of this message | ||
ID: 29474
Updated by: wez@php.net
Reported By: cucup at bol dot com dot br
Status: Closed
Bug Type: Unknown/Other Function
Operating System: Windows 98
PHP Version: 5.0.0
New Comment:
BTW: the u in usleep comes from "mu", the greek symbol used to denote
microseconds, not milliseconds. usleep(500) is much shorter than 1/2
second.
Previous Comments:
------------------------------------------------------------------------
[2004-08-01 02:36:33] wez@php.net
Fixed this properly in CVS; the next batch of snapshots at
http://snaps.php.net will contain the fix.
FYI: Sleep() with fractional arguments is not real usleep(), take a
look at win32/time.c for a working implementation.
------------------------------------------------------------------------
[2004-07-31 22:40:43] cucup at bol dot com dot br
Description:
------------
Function usleep doesn't work under Windows.
I know this is documented, but I believe PHP5 could have this function
working fine... Why not?
Function "sleep" isn't enough for a lot of projects.
There's a bug report in version 4.xx, in wich "dror at europe dot com"
reported a solution for the source code.. It could be easily
implemented in official PHP5 Source.
PHP_FUNCTION(usleep)
{
pval **num;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) ==
FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
#### Begin modifications from original source
#if HAVE_USLEEP
usleep((*num)->value.lval);
#elif PHP_WIN32
Sleep( ((*num)->value.lval+999)/1000);
#endif
#### End modifications
}
Reproduce code:
---------------
echo "Sleeping half second:";
usleep(500); // doesn't work under windows.. :(
Expected result:
----------------
Stop script execution for 1/2 second, or 500ms
Actual result:
--------------
Nothing happens, line is ignored.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29474&edit=1