Simon Slavin wrote:
> On 26 Sep 2012, at 5:42am, Dan Kennedy <danielk1...@gmail.com> wrote:
>> So when SQLite requires a temporary
>> file, it normally creates and opens a file with a randomized name
>> in /tmp then calls unlink() on it immediately - before it starts
>> using the file.
>
> [...] There are problems with doing this under some versions of Unix/
> Linux, and especially variants like Android.  For instance, another
> user/app can make a file with the same name.

Andorid doesn't have a shared /tmp.  In any case, temporary files are
opened with O_CREAT|O_EXCL, so two apps will never accidentally open
each other's file.  Furthermore, by deleting the file immediately after
creating it, the time window in which a conflict is possible is made as
short as possible.

> Or the system may crash while the file is still open.

How would a file that clogs up /tmp be preferrable to some unnamed data
that will be automatically removed from the file system by the fsck
after the crash?

> Is there any chance that the use of this trick can be discontinued ?

This is not a trick, it's a widely used Unix idiom.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to