Things UNIX can do atomically
rcrowley.org
Things UNIX can do atomically
1–10 of 41 posts
Re: Things UNIX can do atomically
#2That doesn't mean this trick is useless, but calling it "atomic" is wrong, and opens up the possibility of bugs (likely security holes, even) if someone actually needs atomicity.
Re: Things UNIX can do atomically
#3Re: Things UNIX can do atomically
#4Re: Things UNIX can do atomically
#5Re: Things UNIX can do atomically
#6The very first example ("mv -T" to retarget a symlink, something I didn't know about and that the manpage is silent on) is not atomic! The symlink(2) syscall will not overwrite an existing directory entry. You have to call unlink(2) first, which opens a race. That doesn't mean this trick is useless, but calling it "atomic" is wrong, and opens up the possibility of bugs (likely security holes, even) if someone actuall…
Re: Things UNIX can do atomically
#7The very first example ("mv -T" to retarget a symlink, something I didn't know about and that the manpage is silent on) is not atomic! The symlink(2) syscall will not overwrite an existing directory entry. You have to call unlink(2) first, which opens a race. That doesn't mean this trick is useless, but calling it "atomic" is wrong, and opens up the possibility of bugs (likely security holes, even) if someone actuall…
It's specific to GNU Coreutils mv(1).
Re: Things UNIX can do atomically
#8The very first example ("mv -T" to retarget a symlink, something I didn't know about and that the manpage is silent on) is not atomic! The symlink(2) syscall will not overwrite an existing directory entry. You have to call unlink(2) first, which opens a race. That doesn't mean this trick is useless, but calling it "atomic" is wrong, and opens up the possibility of bugs (likely security holes, even) if someone actuall…
To change a symlink I use: ln -snf NEW_SOURCE TARGET
This kind of tool merely runs really fast. The race condition is still there.
Re: Things UNIX can do atomically
#9 pipe(&pipefd);
assert(len
Also, if a file is opened O_APPEND, the seek before every write is atomic, but since writes in general aren't atomic I'm not sure what value that has.Re: Things UNIX can do atomically
#10I have a copy of "Advanced Programming in the UNIX Environment, Second Edition" (featuring very good description of C/POSIX/SuS/XSI protocols/api's and programming techniques for Linux/BSD/OSX/Solaris/other UNIX systems). Anyone who seriously wants to do thread safe multiprocessing or other complex low level stuff on UNIX platforms should have a copy of it. It's basically "the book" on the topic.