lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Christian Vogler wrote:
[...]
> handle = mkstemp(filename)

    **** race condition here! If the process' umask isn't set correctly,
         another process might open the file. ****

> chmod(handle) such that file is only readable and writable by owner
> unlink(filename)
> ... use file ..
> close(handle)

tmpfile() is a better option; it's defined to do this stuff *for* you, so
you don't have to, and risk getting it wrong.

-- 
+- David Given --McQ-+ "If you're up against someone more intelligent
|  dg@cowlark.com    | than you are, do something insane and let him think
| (dg@tao-group.com) | himself to death." --- Pyanfar Chanur
+- www.cowlark.com --+