[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: opening twice with O_RDWR

From: Paul Pluzhnikov
Subject: Re: opening twice with O_RDWR
Date: Sun, 31 Dec 2006 13:10:26 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Mike - EMAIL IGNORED <> writes:

> My purpose is not relevant,

It is, if you want a useful answer.

> but I assure you that the requirement is correctly stated.

Where did you state your requirements? I must have missed that.
So far all I've seen is incoherent "when I do this, result is not
what I expect".

> I confirmed that I can open the file O_RDWR simultaneously from
> two processes.

Yes, that's correct on UNIX; but not on Win32.

Note that (AFAICT) you never mentioned two processes before this
point, so the answers you've got related to a *single* process.

> Seems to me like a good way to make a mess of a file.

If you want multiple processes to cooperate on writing a single file,
the proper way to achive that is with "advisory file locking"; see
"man flock".

> I guess I will use a locking file opened from a singleton.

This approach has the problem that if "lock holder" dies, then no
other process can do anything until "manual" cleanup. Advisory
file locking avoids that -- the locks are cleaned by kernel when
the process dies.

Also, whether the locking file is opened from singleton or not is
irrelevant -- singleton doesn't help you in any way that I can see
(given your statement of the problem so far), and singleton doesn't
work across processes.

Finally, may I suggest some light reading for the New Year:

In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]