Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/lib/ape/man/3/tmpfile

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "TMPFILE" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" tmpfile 
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
tmpfile \- create a temporary file
.SH SYNOPSIS
.LP
\fB#include <stdio.h>
.br
.sp
FILE *tmpfile(void);
.br
\fP
.SH DESCRIPTION
.LP
The \fItmpfile\fP() 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. The file is opened
as in \fIfopen\fP()
for update (\fIw\fP+).
.LP
In
some implementations, a permanent file may be left behind if the process
calling \fItmpfile\fP() is killed while it is processing
a call to \fItmpfile\fP().
.LP
An error message may be written to standard error if the stream cannot
be opened. 
.SH RETURN VALUE
.LP
Upon successful completion, \fItmpfile\fP() shall return a pointer
to the stream of the file that is created. Otherwise, it
shall return a null pointer  and set \fIerrno\fP to indicate the
error. 
.SH ERRORS
.LP
The \fItmpfile\fP() function shall fail if:
.TP 7
.B EINTR
A
signal was caught during \fItmpfile\fP(). 
.TP 7
.B EMFILE
{OPEN_MAX} file descriptors are currently open in the calling process.
.TP 7
.B ENFILE
The maximum allowable number of files is currently open in the system.
.TP 7
.B ENOSPC
The directory or file system which would contain the new file cannot
be expanded. 
.TP 7
.B EOVERFLOW
The file is a regular file and the size of the file cannot be represented
correctly in an object of type \fBoff_t\fP. 
.sp
.LP
The \fItmpfile\fP() function may fail if:
.TP 7
.B EMFILE
{FOPEN_MAX} streams are currently open in the calling process. 
.TP 7
.B ENOMEM
Insufficient storage space is available. 
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.SS Creating a Temporary File
.LP
The following example creates a temporary file for update, and returns
a pointer to a stream for the created file in the
\fIfp\fP variable.
.sp
.RS
.nf

\fB#include <stdio.h>
\&...
FILE *fp;
.sp

fp = tmpfile ();
\fP
.fi
.RE
.SH APPLICATION USAGE
.LP
It should be possible to open at least {TMP_MAX} temporary files during
the lifetime of the program (this limit may be shared
with \fItmpnam\fP()) and there should be no limit on the number simultaneously
open other
than this limit and any limit on the number of open files ( {FOPEN_MAX}).
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIfopen\fP(), \fItmpnam\fP(), \fIunlink\fP(),
the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<stdio.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 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 .

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.