TMPFILE(3) Linux Programmer's Manual TMPFILE(3)
NAME
tmpfile - create a temporary file(1,n)
SYNOPSIS
#include <stdio.h>
FILE *tmpfile (void);
DESCRIPTION
The tmpfile() function generates a unique temporary filename. The tem-
porary file(1,n) is then opened in(1,8) binary read(2,n,1 builtins)/write(1,2) (w+b) mode. The file(1,n)
will be automatically deleted when it is closed or the program termi-
nates normally.
RETURN VALUE
The tmpfile() function returns a stream descriptor, or NULL if(3,n) a unique
filename cannot be generated or the unique file(1,n) cannot be opened. In
the latter case, errno is set(7,n,1 builtins) to indicate the error.
ERRORS
EACCES Search permission denied for directory in(1,8) file(1,n)'s path prefix.
EEXIST Unable to generate a unique filename.
EINTR The call was interrupted by a signal.
EMFILE Too many file(1,n) descriptors in(1,8) use by the process.
ENFILE Too many files open(2,3,n) in(1,8) the system.
ENOSPC There was no room in(1,8) the directory to add the new filename.
EROFS Read-only filesystem.
CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899, SUSv2
NOTES
An error(8,n) message may be written to stdout if(3,n) the stream cannot be
opened.
The standard does not specify the directory that tmpfile() will use.
Glibc will try the path prefix P_tmpdir defined in(1,8) <stdio.h>, and if(3,n)
that fails the directory /tmp.
SEE ALSO
exit(3,n,1 builtins)(3), mkstemp(3), mktemp(1,3)(3), tempnam(3), tmpnam(3)
2001-11-17 TMPFILE(3)