The mkstemp() function replaces the contents of the string pointed to by template by a unique file name, and returns a file descriptor for the file open for
reading and writing. The function thus prevents any possible race condition between testing whether the file exists and opening it for use. The string in template should look like
a file name with six trailing 'X's; mkstemp() replaces each 'X' with a character from the portable file name character set. The characters are chosen such that the resulting name does
not duplicate the name of an existing file.