From:             cucup at bol dot com dot br
Operating system: Windows 98
PHP version:      5.0.0
PHP Bug Type:     Unknown/Other Function
Bug description:  Function usleep doesn't work under Windows.

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 bug report at http://bugs.php.net/?id=29474&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29474&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29474&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29474&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29474&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29474&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29474&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29474&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29474&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29474&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29474&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29474&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29474&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29474&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29474&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29474&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29474&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29474&r=float

Reply via email to