Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25227 > unrolled thread
| Started by | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| First post | 2012-07-12 19:38 +0200 |
| Last post | 2012-07-12 19:38 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to safely maintain a status file Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-12 19:38 +0200
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-07-12 19:38 +0200 |
| Subject | Re: How to safely maintain a status file |
| Message-ID | <mailman.2051.1342114916.4697.python-list@python.org> |
> Sorry, but you are wrong. It's just one operation that boils down to > "point name to a different inode". After the rename op the file name > either points to a different inode or still to the old name in case of > an error. The OS guarantees that all processes either see the first or > second state (in other words: atomic). > > POSIX has no operation that actually deletes a file. It just has an > unlink() syscall that removes an associated name from an inode. As soon > as an inode has no names and is not references by a file descriptor, the > file content and inode is removed by the operating system. rename() is > more like a link() followed by an unlink() wrapped in a system wide > global lock. Then please help me understand this. "Good" case: process #1: unlink(old status file) process #1: rename(new status file) process#2: open(new status file) process#2: read(new status file) "Bad" case: process #1: unlink(old status file) process#2: open(???) -- there is no file on disk here, this system call returns with an error! process #1: rename(new status file) If it would be possible to rename + unlink in one step, then it would be okay. Can you please explain what am I missing?
Back to top | Article view | comp.lang.python
csiph-web