On Wed, 23 Jun 2004 15:50:05 -0400, Andrew Langmead [EMAIL PROTECTED] wrote:
[snip]
The parent downgrades its | The child sleeps for 1
sec.
lock from exclusive to shared |
[snip]
If you need for the parent to do the tests, then I think
On Wednesday, June 23, 2004, at 05:25 PM, Ian Langworth wrote:
Hrm, I guess the confusion is in the downgrading, as I believed that
the parent was getting a new lock completely.
In some ways, you could treat it as giving up one lock and acquiring
another. The only difference is that the process
On Mon, Jun 21, 2004 at 10:10:02PM -0400, Ian Langworth wrote:
fork() returns the child process id in the parent and 0 in the child,
so
fork and do {
This block executes in the parent process.
};
The remaining code executes in the child, which will have no lock after the
fork on systems
On Mon, Jun 21, 2004 at 10:10:02PM -0400, Ian Langworth wrote:
--
use Test::More 'no_plan';
use Fcntl ':flock';
open ONE, foo or die $!;
flock ONE, LOCK_EX or die Can't lock;
print ONE line 1\n;
fork and do {
The test on this line is incorrect.
i have used a mkdir lock and not flock. it is very portable, works on
nfs and doesn't have the quirks that flock does. i stole the idea from
the perl cookbook but i rolled my own version (as usual).
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl
Besides the comments about the inverted test on the return from fork(),
another issue to bring up is that the LOCK_UN is usually unnecessary,
and can even be detrimental. A close() doesn't an implicit flush and
unlock. Traditionally, if you unlocked before closing, you did the last
write
Does anyone know of any gotcha's regarding file locking on Solaris?
Theoretically, the following should work, as the forked process should
block until a lock is available. I've tried this on and off NFS, and
this *does* work on Linux.
Maybe a platform-specific solution involving fcntl() is in
On Mon, 21 Jun 2004 18:49:22 -0400, Andrew Langmead [EMAIL PROTECTED] wrote:
The example code that you imply would follow wasn't in your posting.
Ooops. See below.
...I was
always taught that locks are not kept across forks, that locks are
designed to coordinate access among multiple