[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: mkstemp
- From: Christian Vogler <Christian.Vogler@...>
- Date: Sat, 15 Apr 2006 16:46:15 -0400
On Saturday 15 April 2006 04:08 pm, Alex Queiroz wrote:
> But Lua closes the file anyway, just before returning the name.
> Using mkstemp will not avoid a race condition in this case.
Ugh. Really? The correct usage of mkstemp would be something like this:
handle = mkstemp(filename)
chmod(handle) such that file is only readable and writable by owner
unlink(filename)
... use file ..
close(handle)
This also ensures that the file is deleted after it is closed.
I agree that if Lua uses mkstemp just to create a name, it is no better than
using tmpnam.
- Christian