3 ms·
Reading a file is not even atomic - you can race with concurrent writes. The only safe way to update a config file of a running service is with POSIX atomic re
by efaref 11y ago
Reading a file is not even atomic - you can race with concurrent writes.
The only safe way to update a config file of a running service is with POSIX atomic rename, and most editors don't do that by default.
- bad_user 11y agoThat's true, that's why I said that it "can be". And if you have a special edit command, like "systemctl edit", then it can take care of the details for you, which is I presume the reason for its existence (much like visudo).
- pjc50 11y agoIf only the operating system maintained a tree-structured key-value configuration store with atomic updates, like the Windows registry. (Even I'm not sure if this is sarcasm any more)
- bad_user 11y agoThe Windows Registry is a dump on disk of some half-assed structures defined in a memory heap, poorly specified, being in essence a file-system as well. Also, only individual operations have been atomic and one update in the Windows Registry does not equal one update of an entire configuration file on Linux. Transactional support has been added, but late and interactions with it are still problematic. The Internet is filled with complaints and pieces of advice on corrupted registries. And it is being obsoleted, with the elephant in the room being that the Windows Registry needs to be thread-safe because it's a central store of all settings and this was a really bad idea. I'll also have my nginx.conf over a registry entries file any day of the week.