1TMPFILE(3P)                POSIX Programmer's Manual               TMPFILE(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       tmpfile - create a temporary file
13

SYNOPSIS

15       #include <stdio.h>
16
17       FILE *tmpfile(void);
18
19

DESCRIPTION

21       The tmpfile() function shall create a temporary file and open a  corre‐
22       sponding  stream. The file shall be automatically deleted when all ref‐
23       erences to the file are closed. The file is opened as  in  fopen()  for
24       update (w+).
25
26       In  some  implementations,  a  permanent file may be left behind if the
27       process calling tmpfile() is killed while it is processing  a  call  to
28       tmpfile().
29
30       An  error message may be written to standard error if the stream cannot
31       be opened.
32

RETURN VALUE

34       Upon successful completion, tmpfile() shall return  a  pointer  to  the
35       stream  of  the file that is created. Otherwise, it shall return a null
36       pointer  and set errno to indicate the error.
37

ERRORS

39       The tmpfile() function shall fail if:
40
41       EINTR  A signal was caught during tmpfile().
42
43       EMFILE {OPEN_MAX} file descriptors are currently open  in  the  calling
44              process.
45
46       ENFILE The  maximum  allowable number of files is currently open in the
47              system.
48
49       ENOSPC The directory or file system which would contain  the  new  file
50              cannot be expanded.
51
52       EOVERFLOW
53              The  file  is  a regular file and the size of the file cannot be
54              represented correctly in an object of type off_t.
55
56
57       The tmpfile() function may fail if:
58
59       EMFILE {FOPEN_MAX} streams are currently open in the calling process.
60
61       ENOMEM Insufficient storage space is available.
62
63
64       The following sections are informative.
65

EXAMPLES

67   Creating a Temporary File
68       The following example creates a temporary file for update, and  returns
69       a pointer to a stream for the created file in the fp variable.
70
71
72              #include <stdio.h>
73              ...
74              FILE *fp;
75
76
77              fp = tmpfile ();
78

APPLICATION USAGE

80       It should be possible to open at least {TMP_MAX} temporary files during
81       the lifetime of the program (this limit may be  shared  with  tmpnam())
82       and  there  should  be no limit on the number simultaneously open other
83       than  this  limit  and  any  limit  on  the  number  of  open  files  (
84       {FOPEN_MAX}).
85

RATIONALE

87       None.
88

FUTURE DIRECTIONS

90       None.
91

SEE ALSO

93       fopen(),   tmpnam(),   unlink(),   the   Base   Definitions  volume  of
94       IEEE Std 1003.1-2001, <stdio.h>
95
97       Portions of this text are reprinted and reproduced in  electronic  form
98       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
99       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
100       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
101       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
102       event of any discrepancy between this version and the original IEEE and
103       The Open Group Standard, the original IEEE and The Open Group  Standard
104       is  the  referee document. The original Standard can be obtained online
105       at http://www.opengroup.org/unix/online.html .
106
107
108
109IEEE/The Open Group                  2003                          TMPFILE(3P)
Impressum