Re: Editor which would set write lock on the file
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com 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 ? 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Jens Alfke