MKUNIQUE(3)

NAME
mkunique, tmpnam - make a file with a unique name

SYNOPSIS
char *mkunique(template, mode, fdp)
char *template;
int *fdp;

tmpnam(s)
char *s;

DESCRIPTION
Mkunique creates a file with a unique name and the specified mode and returns a pointer to a malloc(3)-ed copy of the unique name.

If the new file resides in an ordinary directory, the unique name will be the template suffixed by 8 digits, the first 5 of which are the current process id. The last component of the template should not be more than 6 characters long. In a blind directory, the entire last component of the unique name will be a random string; see creat(2).

If the pointer fdp is nonzero, the location pointed to will be filled in with a file descriptor for the file, open for writing.

Note. It is bad form to leave files in the temporary directory. One way to avoid doing so is to unlink(2) temporary files as soon as they are opened.

SEE ALSO
tmpnam(1)

DIAGNOSTICS
Zero is returned if the operation fails for any reason.