This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16285] thread-safe file locking (using lock file)
- From: "wolfgang at contre dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 03 Dec 2013 13:17:00 +0000
- Subject: [Bug libc/16285] thread-safe file locking (using lock file)
- Auto-submitted: auto-generated
- References: <bug-16285-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=16285
--- Comment #4 from Wolfgang Sourdeau <wolfgang at contre dot com> ---
(In reply to Rich Felker from comment #3)
> Normally for this kind of thing, you write into a unique temporary file and
> rename (which is atomic) to the actual name only when the file is complete.
> This avoids all the issues you're concerned about, I believe.
(thank you for your quick responses!)
Actually the problem is still the same, for the reason that renaming can
overwrite the target file, which does not solve the race condition.
The other solution I thought about was to hard link a file, since this too
renders the file content atomically, but then it requires an unlink + link
phase which causes the race condition again.
--
You are receiving this mail because:
You are on the CC list for the bug.