MKTEMP(3) BSD Programmer's Manual MKTEMP(3) NNAAMMEE mmkktteemmpp - make temporary file name (unique) SSYYNNOOPPSSIISS ##iinncclluuddee <<uunniissttdd..hh>> _c_h_a_r _* mmkktteemmpp(_c_h_a_r _*_t_e_m_p_l_a_t_e); _i_n_t mmkksstteemmpp(_c_h_a_r _*_t_e_m_p_l_a_t_e); DDEESSCCRRIIPPTTIIOONN The mmkktteemmpp() function takes the given file name template and overwrites a portion of it to create a file name. This file name is unique and suit- able for use by the application. The template may be any file name with some number of `Xs' appended to it, for example _/_t_m_p_/_t_e_m_p_._X_X_X_X. The trailing `Xs' are replaced with the current process number and/or a unique letter combination. The number of unique file names mmkktteemmpp() can return depends on the number of `Xs' provided; six `Xs' will result in mmkktteemmpp() testing roughly 26 ** 6 combinations. The mmkksstteemmpp() function 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 VVAALLUUEESS The mmkktteemmpp() function returns a pointer to the template on success and NULL on failure. The mmkksstteemmpp() function returns -1 if no suitable file could be created. If either call fails an error code is placed in the global variable _e_r_r_n_o. EERRRROORRSS The mmkktteemmpp() and mmkksstteemmpp() functions may set _e_r_r_n_o to one of the follow- ing values: [ENOTDIR] The pathname portion of the template is not an existing direc- tory. The mmkktteemmpp() and mmkksstteemmpp() functions may also set _e_r_r_n_o to any value specified by the stat(2) function. The mmkksstteemmpp() function may also set _e_r_r_n_o to any value specified by the open(2) function. SSEEEE AALLSSOO chmod(2), getpid(2), open(2), stat(2) HHIISSTTOORRYY A mmkktteemmpp function appeared in Version 7 AT&T UNIX. 4.4BSD June 4, 1993 1