|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29474 Function usleep doesn't work under Windows.
Submitted: 2004-07-31 22:40 UTC Modified: 2004-08-01 02:39 UTC
From: cucup at bol dot com dot br Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.0.0 OS: Windows 98
Private report: No CVE-ID: None
 [2004-07-31 22:40 UTC] cucup at bol dot com dot br
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.

	pval **num;

	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE)

#### Begin modifications from original source
#elif PHP_WIN32
   Sleep( ((*num)->value.lval+999)/1000);
#### 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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-01 02:36 UTC]
Fixed this properly in CVS; the next batch of snapshots at 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-08-01 02:39 UTC]
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.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:25 2019 UTC