MKTEMP(3) BSD MKTEMP(3)
NAME
mktemp, mkstemp - make a unique filename
SYNOPSIS
char *mktemp(template)
char *template;
fd = mkstemp(template)
int fd;
char *template;
DESCRIPTION
mktemp creates a unique filename, typically in a temporary file system,
by replacing template with a unique filename, and returns the address of
the template. The template should contain a filename with six trailing
Xs, which are replaced with the current process ID and a unique letter.
mkstemp makes the same replacement to the template but returns a file
descriptor for the template file open for reading and writing. mkstemp
avoids the race between testing whether the file exists and opening it
for use.
SEE ALSO
getpid(2), open(2)
DIAGNOSTICS
mkstemp returns an open file descriptor upon success. It returns -1 if
no suitable file could be created.