1TMPFILE(3)                 Linux Programmer's Manual                TMPFILE(3)
2
3
4

NAME

6       tmpfile - create a temporary file
7

SYNOPSIS

9       #include <stdio.h>
10
11       FILE *tmpfile(void);
12

DESCRIPTION

14       The  tmpfile()  function  opens  a  unique  temporary  file  in  binary
15       read/write (w+b) mode.  The file will be automatically deleted when  it
16       is closed or the program terminates.
17

RETURN VALUE

19       The tmpfile() function returns a stream descriptor, or NULL if a unique
20       filename cannot be generated or the unique file cannot be  opened.   In
21       the latter case, errno is set to indicate the error.
22

ERRORS

24       EACCES Search permission denied for directory in file's path prefix.
25
26       EEXIST Unable to generate a unique filename.
27
28       EINTR  The call was interrupted by a signal; see signal(7).
29
30       EMFILE The per-process limit on the number of open file descriptors has
31              been reached.
32
33       ENFILE The system-wide limit on the total number of open files has been
34              reached.
35
36       ENOSPC There was no room in the directory to add the new filename.
37
38       EROFS  Read-only filesystem.
39

ATTRIBUTES

41       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
42       tributes(7).
43
44       ┌────────────────────────────────────────────┬───────────────┬─────────┐
45Interface                                   Attribute     Value   
46       ├────────────────────────────────────────────┼───────────────┼─────────┤
47tmpfile()                                   │ Thread safety │ MT-Safe │
48       └────────────────────────────────────────────┴───────────────┴─────────┘
49

CONFORMING TO

51       POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD, SUSv2.
52

NOTES

54       POSIX.1-2001 specifies: an error message may be written  to  stdout  if
55       the stream cannot be opened.
56
57       The  standard  does  not specify the directory that tmpfile() will use.
58       Glibc will try the path prefix P_tmpdir defined in  <stdio.h>,  and  if
59       that fails, then the directory /tmp.
60

SEE ALSO

62       exit(3), mkstemp(3), mktemp(3), tempnam(3), tmpnam(3)
63

COLOPHON

65       This  page  is  part of release 5.13 of the Linux man-pages project.  A
66       description of the project, information about reporting bugs,  and  the
67       latest     version     of     this    page,    can    be    found    at
68       https://www.kernel.org/doc/man-pages/.
69
70
71
72                                  2021-03-22                        TMPFILE(3)
Impressum