Bug #65272 [NEW]: flock() documentation says LOCK_NB is not available on Windows, although it is

From: Date: Tue, 16 Jul 2013 15:09:10 +0000
Subject: Bug #65272 [NEW]: flock() documentation says LOCK_NB is not available on Windows, although it is
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10083@lists.php.net to get a copy of this message
From: benjamin dot morel at gmail dot com Operating system: N/A PHP version: Irrelevant Package: Documentation problem Bug Type: Bug Bug description:flock() documentation says LOCK_NB is not available on Windows, although it is Description: ------------ The flock() documentation: http://php.net/manual/en/function.flock.php Says: It is also possible to add LOCK_NB as a bitmask to one of the above operations if you don't want flock() to block while locking. (not supported on Windows) In my tests on Windows 7 x64, it does work. But what is true is that the failed flock() does not set &$wouldblock to 1. Please see the test script below. Both scripts must be run at the same time in PHP interactive mode or with a sleep() to avoid the lock being released automatically. It would be interesting to test this behaviour on other versions of Windows (this might not be applicable to all of them), and update the documentation accordingly. Non-blocking locks are a really useful feature, and it would be nice to document this properly for Windows users. Test script: --------------- Script 1 -------- $f = fopen('file.txt', 'w'); var_export(flock($f, LOCK_EX | LOCK_NB, $wouldblock)); // true var_export($wouldblock); // 0 Script 2 -------- $f = fopen('file.txt', 'w'); var_export(flock($f, LOCK_EX | LOCK_NB, $wouldblock)); // false var_export($wouldblock); // 0 (1 on Linux) -- Edit bug report at https://bugs.php.net/bug.php?id=65272&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65272&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65272&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65272&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65272&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65272&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65272&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65272&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65272&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65272&r=support Expected behavior: https://bugs.php.net/fix.php?id=65272&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65272&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65272&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65272&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65272&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65272&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65272&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65272&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65272&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65272&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65272&r=mysqlcfg

« previous php.doc.bugs (#10083) next »