News for hackers. Stuff that matters.
Re:Everything is Unix by cnvogel on Tuesday October 13, 2009 @06:50AM (#878798)
His contrived example of "atomically creating a file" is kind of strange. If you would want to see which of several processes wins at creating a file, just use if(-1 != (fd=open("filename",0666,O_CREAT|O_EXCL)){ .. } which is guaranteed to suceed only for one program. Or you'd open it without O_EXCL and try locking it. Creating several file and atomically renaming it "over" the old file yields you nothing, because whenver you try to access it afterwards, you have no guarantee that it's not being overwritten just afterwards by another one of the processes.

There are no comments on this comment yet.