Re: Editor which would set write lock on the file
Re: Editor which would set write lock on the file
- Subject: Re: Editor which would set write lock on the file
- From: Jens Alfke <email@hidden>
- Date: Mon, 26 Oct 2009 08:21:12 -0700
On Oct 26, 2009, at 6:04 AM, rohan a wrote:
I am trying to backup a file by setting a shared(read) lock on it. I
need to test this locking by writing to the file with an editor that
would set a write-lock on it. Which editor can I use ?
I can't think of any program that would do this. The usual design
pattern is to read the file into memory and immediately close it. When
saving, it writes a new file and then calls rename() to replace the
old file atomically with the new one.
Apps that use database-like files (such as CoreData based apps) would
leave the file open, but probably not take out a write lock until the
moment they try to save. (SQLite works this way.)
If you just want to test your app, it would be trivial to write a
little tool that opens a file with O_EXLOCK and then just blocks till
you kill it.
What exactly are you trying to do in your program?
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden