From: dmitry at koteroff dot ru
Operating system: Windows NT, 2000, XP, 2003
PHP version: 4.3.4
PHP Bug Type: Filesystem function related
Bug description: flock() bug
Description:
------------
This code does not work on Windows:
<?
$f1 = fopen("/tmp/a", "a+b");
flock($f1, LOCK_SH);
$f2 = fopen("/tmp/a", "r+b");
fwrite($f2, "test");
?>
It creates zero-length file. On Linux everything is OK.
If I delete flock() or call flock($f1, LOCK_UN) just after first flock(),
all works correctly.
Flock() is ADVISORY lock, but it works as mandatory lock. Bad luck.
Reproduce code:
---------------
$f1 = fopen("/tmp/a", "a+b");
flock($f1, LOCK_SH);
$f2 = fopen("/tmp/a", "r+b");
fwrite($f2, "test");
Expected result:
----------------
Create non-empty file.
Actual result:
--------------
Creates empty file.
--
Edit bug report at http://bugs.php.net/?id=27256&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27256&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27256&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27256&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27256&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27256&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27256&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27256&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27256&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27256&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27256&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27256&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27256&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27256&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27256&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27256&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27256&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27256&r=float