php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #13919 flock not working
Submitted: 2001-11-04 07:02 UTC Modified: 2002-06-10 06:36 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Julienc at psychologie-fr dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.6 OS: Windows 98
Private report: No CVE-ID: None
 [2001-11-04 07:02 UTC] Julienc at psychologie-fr dot com
flock($fp,2); alwas return false using windows 98. Here a  little testcase:

$fp=fopen ('myfile.txt','a');
if ( $fp != 0 && flock($fp, 2) ){
	fwrite($fp, $mydatas);
} else {
	echo 'error';		
}
fclose($fp);


Other people having the prob: Bug#11828 and 2 users contributed notes (sebastian.theek@gmx.de, manuel.ricca@mail.pt)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-02 15:42 UTC] k.schroeder@php.net
File locking isn't supported by windows.

Please use the workaround from sbsaylors@yahoo.com:
"Well I needed some kind of "lock" in windows, so I just created a lock.file in that directory. So if anything wants to 'write' to that file (or append, whatever) it checks to see if a lock.file (or whatever name you want to use) is there and if the date of the file is old.  If its old (1 hour) then it deletes it and goes ahead.  If its not old then it waits a random time.  When its finised it deletes the file.

Seems to work alright but I havent tested anything and its only used for maybe a 100 hits a day but... :)"
(User Contributed Notes, http://www.php.net/manual/en/function.flock.php)

Regards, Kai
 [2002-06-02 16:53 UTC] mfischer@php.net
It would be quite a benefit to incooperate this user contributed note into the manual, reclassifying.
 [2002-06-10 06:36 UTC] mfischer@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 05 22:01:30 2025 UTC