TMPFILE(3POSIX)
π TMPFILE(3POSIX) π
okay so bestie, welcome to the POSIX Programmer's Manual β¨ this lil page is all about tmpfile, and it's giving temporary file realness. stay with me, it's gonna be cute AND useful, i promise π«Ά
πΈ PROLOG πΈ
so, first things first β this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (bestie, pls consult the corresponding Linux manual page for the details of Linux behavior), or honestly?? the interface may not even be implemented on Linux at all. π
π NAME π
tmpfile β create a temporary file π
β¨ SYNOPSIS β¨
#include <stdio.h>
FILE *tmpfile(void);
π¦ DESCRIPTION π¦
the functionality described on this reference page is aligned with the ISO C standard. and like, if there's any conflict between the requirements described here and the ISO C standard? that's unintentional, bestie. this volume of POSIX.1β2017 defers to the ISO C standard. periodt. π
the tmpfile() function shall create a temporary file and open a corresponding stream. the file shall be automatically deleted when all references to the file are closed. no cleanup on your part, she handles herself. the file shall be opened as in fopen() for update (wb+), except that implementations may restrict the permissions, either by clearing the file mode bits or setting them to the value S_IRUSR | S_IWUSR.
β οΈ heads up bestie: in some implementations, a permanent file may be left behind if the process callingtmpfile()is killed while it is processing a call totmpfile(). so like, don't get murked mid-call, okay?? π
an error message may be written to standard error if the stream cannot be opened.
π RETURN VALUE π
upon successful completion, tmpfile() shall return a pointer to the stream of the file that is created. π otherwise, it shall return a null pointer and set errno to indicate the error. sad girl hours fr fr.
π ERRORS π
the tmpfile() function shall fail if:
EINTRβ a signal was caught duringtmpfile(). rude tbh.EMFILEβ all file descriptors available to the process are currently open.EMFILEβ{STREAM_MAX}streams are currently open in the calling process.ENFILEβ the maximum allowable number of files is currently open in the system.ENOSPCβ the directory or file system which would contain the new file cannot be expanded. no room bestie, the vibes are full. πEOVERFLOWβ the file is a regular file and the size of the file cannot be represented correctly in an object of typeoff_t.
the tmpfile() function may fail if:
EMFILEβ{FOPEN_MAX}streams are currently open in the calling process.ENOMEMβ insufficient storage space is available.
the following sections are informative.
π§ EXAMPLES π§
π Creating a Temporary File
the following example creates a temporary file for update, and returns a pointer to a stream for the created file in the fp variable. slay.
#include <stdio.h>
...
FILE *fp;
fp = tmpfile ();
π APPLICATION USAGE π
it should be possible to open at least {TMP_MAX} temporary files during the lifetime of the program (this limit may be shared with tmpnam()) and there should be no limit on the number simultaneously open other than this limit and any limit on the number of open file descriptors or streams ({OPEN_MAX}, {FOPEN_MAX}, {STREAM_MAX}). so like, go off, open as many as you want (within reason, obviously). β¨
π RATIONALE π
None. (she's mysterious like that. no thoughts, head empty, iconic behavior.) π
β FUTURE DIRECTIONS β
None. (same energy. no notes. periodt.) π
π₯ SEE ALSO π₯
- Section 2.5, Standard I/O Streams,
fopen(),mkdtemp(),tmpnam(),unlink() - The Base Definitions volume of POSIX.1β2017,
<stdio.h>
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay bestie that's the whole page, and yes the whole thing is brought to you by IEEE/The Open Group, 2017 β TMPFILE(3POSIX) π mwah, go make some temp files, drink water, and remember: close your streams. πΈβ¨π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms