1MKTEMP(3) Library Functions Manual MKTEMP(3)
2
3
4
6 mktemp - make a unique file name
7
9 char *mktemp(template)
10 char *template;
11
12 mkstemp(template)
13 char *template;
14
16 Mktemp creates a unique file name and returns the address of the tem‐
17 plate. The template should contain a file name with trailing X's, nor‐
18 mally something like /tmp/tempXXXXXX. The X's are replaced by the cur‐
19 rent process number and/or a unique letter combination. Mkstemp makes
20 the same replacement to the template but opens the template file and
21 returns a file descriptor open for reading and writing. Mkstemp avoids
22 the race between testing whether the file exists and opening it for
23 use. The number of file name combinations mktemp and mkstemp will try
24 depends on the number of X's placed on the end of the template; six X's
25 will result in them trying roughly 26 ** 6 combinations.
26
28 access(2), getpid(2), open(2)
29
31 Mktemp returns NULL on failure, mkstemp returns -1 if no suitable file
32 could be created.
33
34
35
367th Edition April 10, 1987 MKTEMP(3)