xref: /original-bsd/lib/libc/stdio/mktemp.3 (revision b0ceb3f2)
@(#)mktemp.3 6.4 (Berkeley) 12/21/88

MKTEMP 3 ""
.AT 3
NAME
mktemp - make a unique file name
SYNOPSIS
 char *mktemp(template)  char *template;  mkstemp(template)  char *template; 
DESCRIPTION
Mktemp creates a unique file name and returns the address of the template. The template should contain a file name with trailing X's, normally something like /tmp/tempXXXXXX. The X's are replaced by the current process number and/or a unique letter combination. Mkstemp makes the same replacement to the template but creates the template file, mode 0600, and returns a file descriptor open for reading and writing. Mkstemp avoids the race between testing whether the file exists and opening it for use. The number of file name combinations mktemp and mkstemp will try depends on the number of X's placed on the end of the template; six X's will result in them trying roughly 26 ** 6 combinations.
"SEE ALSO"
chmod(2), getpid(2), open(2), stat(2)
DIAGNOSTICS
Mktemp returns NULL on failure, mkstemp returns -1 if no suitable file could be created.