SCCS-vsn: lib/libc/stdio/mktemp.3 6.2
-.\" @(#)mktemp.3 6.1 (Berkeley) %G%
+.\" @(#)mktemp.3 6.2 (Berkeley) %G%
.\"
.TH MKTEMP 3 ""
.AT 3
.\"
.TH MKTEMP 3 ""
.AT 3
.fi
.SH DESCRIPTION
.I Mktemp
.fi
.SH DESCRIPTION
.I Mktemp
+creates a unique file name, typically in a temporary filesystem,
+by replacing
-by a unique file name, and returns the
+with a unique file name, and returns the
-The template should look like a file name with six trailing
-X's, which will be replaced with the
+The template should contain a file name with six trailing
+X's, which are replaced with the
current process id and a unique letter.
.I Mkstemp
current process id and a unique letter.
.I Mkstemp
-makes the same replacement to the template but returns an open file descriptor
-for the template file suitable for reading or writing.
+makes the same replacement to the template
+but returns a file descriptor
+for the template file open for reading and writing.
-avoids the potential race between the creation of the unique
-file name and its being opened for use.
+avoids the race between testing whether the
+file exists and opening it for use.
+getpid(2), open(2)
+.SH DIAGNOSTICS
+.I Mkstemp
+returns an open file descriptor upon success.
+It returns -1 if no suitable file could be created.