Hi, * Kyle Wheeler [06-10-04 11:36:43 -0400] wrote:
On Wednesday, October 4 at 02:49 PM, quoth Rocco Rutte:
But you still can have races between the test for the existence of the new file and the actual rename and thus loose data.
Wha? I'm not sure what you're saying here. Yes, the rename doesn't test that another file of the same name doesn't already exist, but the same problem already exists for using mktemp. Which, I suppose, is really no better than the current mktemp() method, now that I think about it.
That was what I was trying to say. By using rename() the situation doesn't get any better at all.
On the other hand, mkstemps() would solve the problem, at least for the OS's that support it, i.e. all modern Unixes (it works on Tru64 Unix, Solaris, FreeBSD, OpenBSD, NetBSD, MacOS X, OpenSolaris, Solaris, and Linux). Where it falls down is on HP-UX and older Solaris boxes (that I know of). A portable implementation is included in libiberty, if someone's feeling ambitious enough to add it to mutt.
I don't think a dependency is accetable given that the current approach was good enough for years now.
A configure test for mkstemps() as well as using it should be quite easy. Maybe I'll some minutes this week to do it... but if someone is faster... :-)
bye, Rocco -- :wq!