Email list hosting service & mailing list manager

Temporary files Lassi Kortela (09 May 2019 18:16 UTC)
Re: Temporary files Per Bothner (09 May 2019 18:52 UTC)
Re: Temporary files Lassi Kortela (09 May 2019 18:59 UTC)
Re: Temporary files Lassi Kortela (09 May 2019 19:05 UTC)

Temporary files Lassi Kortela 09 May 2019 18:16 UTC

Some Unix APIs are classic race condition attractors. mktemp() is one
API to avoid because of this. Luckily, create-temp-file in the first
draft is smarter than mktemp(): once it finds an unused temp file name,
it creates a file under that name, thereby "reserving" that name.

It would be good for us to provide an analog to Unix mkstemp() and
mkostemp(). They behave like create-temp-file but return an open file
descriptor instead of the file name.

There's also mkdtemp() to create a temp directory instead of a file.

OpenBSD even has shm_mkstemp() to create a shared memory object with a
guaranteed-unique name.

I think temp file support swould be good to provide in the SRFI since
people want to create temp files anyway, so it's good to make it as safe
as possible. To that end, I suggest a family of functions similar to the
above.

I would leave out procedures that only generate a name without creating
or opening it in any way (unless someone has a good argument for why a
procedure like that is necessary and safe enough).