up | Inhaltsverzeichniss | Kommentar

Manual page for MKTEMP(3)

mktemp, mkstemp - make a unique file name

SYNOPSIS

char *mktemp(template)
char *template;

mkstemp(template) char *template;

DESCRIPTION

mktemp() creates a unique file name, typically in a temporary filesystem, by replacing template with a unique file name, and returns the address of template. The string in template should contain a file name with six trailing Xs; mktemp() replaces the Xs with a letter and the current process ID. The letter will be chosen so that the resulting name does not duplicate an existing file. 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.

Notes:

SEE ALSO

getpid.2v open.2v tmpfile.3s tmpnam.3s

DIAGNOSTICS

mkstemp() returns an open file descriptor upon success. It returns -1 if no suitable file could be created.

mktemp() assigns the null string to template when it cannot create a unique name.

BUGS

It is possible to run out of letters.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97