4.3BSD-Reno/share/man/cat3/mktemp.0
MKTEMP(3) 1990 MKTEMP(3)
NNAAMMEE
mktemp - create a unique file name
SSYYNNOOPPSSIISS
cchhaarr **
mmkktteemmpp((tteemmppllaattee))
cchhaarr **tteemmppllaattee;;
mmkksstteemmpp((tteemmppllaattee))
cchhaarr **tteemmppllaattee;;
DDEESSCCRRIIPPTTIIOONN
_M_k_t_e_m_p takes a file name template and overwrites it to
create a unique file name for use by the application. The
template may be any file name with some number of X's
appended to it, for example ``/tmp/temp.XXXX''. The trail-
ing X's are replaced with the current process number and/or
a unique letter combination. The number of unique file
names _m_k_t_e_m_p can return depends on the number of X's pro-
vided; six X's will result in _m_k_t_e_m_p testing roughly 26 ** 6
combinations.
_M_k_s_t_e_m_p makes the same replacement to the template and
creates the template file, mode 0600, returning a file
descriptor opened for reading and writing. This avoids the
race between testing for a file's existence and opening it
for use.
RREETTUURRNN VVAALLUUEE
_M_k_t_e_m_p returns a pointer to the template on success and NULL
on failure. _M_k_s_t_e_m_p returns -1 if no suitable file could be
created. If either call fails an error code is placed in
the global location _e_r_r_n_o.
EERRRROORRSS
_M_k_t_e_m_p and _m_k_s_t_e_m_p may set _e_r_r_n_o to one of the following
values:
[ENOTDIR]
The pathname portion of the template is not an existing
directory.
_M_k_t_e_m_p and _m_k_s_t_e_m_p may also set _e_r_r_n_o to any value specified
by the _s_t_a_t(2) function. _M_k_s_t_e_m_p may also set _e_r_r_n_o to any
value specified by the _o_p_e_n(2) function.
SSEEEE AALLSSOO
chmod(2), getpid(2), open(2), stat(2)
Printed 7/27/90 June 1