summaryrefslogtreecommitdiffstats
path: root/Doc/libtempfile.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-01 14:36:00 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-01 14:36:00 (GMT)
commit81b3060b1409003625e48e56a49b8e910cc9a2b5 (patch)
treefbf36e8fb67ec1c1f5c708287e473cda355a80b7 /Doc/libtempfile.tex
parent51bbdfb2ffe9cb2bfce56bd7877928d8936ea283 (diff)
downloadcpython-81b3060b1409003625e48e56a49b8e910cc9a2b5.zip
cpython-81b3060b1409003625e48e56a49b8e910cc9a2b5.tar.gz
cpython-81b3060b1409003625e48e56a49b8e910cc9a2b5.tar.bz2
en weer twee!
Diffstat (limited to 'Doc/libtempfile.tex')
-rw-r--r--Doc/libtempfile.tex50
1 files changed, 50 insertions, 0 deletions
diff --git a/Doc/libtempfile.tex b/Doc/libtempfile.tex
new file mode 100644
index 0000000..84bd641
--- /dev/null
+++ b/Doc/libtempfile.tex
@@ -0,0 +1,50 @@
+\section{Built-in module \sectcode{tempfile}}
+\stmodindex{tempfile}
+\indexii{temporary}{file name}
+\indexii{temporary}{file}
+
+\renewcommand{\indexsubitem}{(in module tempfile)}
+
+This module generates temporary file names. It is not UNIX specific,
+but it may require some help on non-UNIX systems.
+
+Note: the modules does not create temporary files, nor does it
+automatically remove them when the current process exits or dies.
+
+The module defines a single user-callable function:
+
+\begin{funcdesc}{mktemp}{}
+Return a unique temporary filename. This is an absolute pathname of a
+file that does not exist at the time the call is made. No two calls
+will return the same filename.
+\end{funcdesc}
+
+The module uses two global variables that tell it how to construct a
+temporary name. The caller may assign values to them; by default they
+are initialized at the first call to \code{mktemp()}.
+
+\begin{datadesc}{tempdir}
+When set to a value other than \code{None}, this variable defines the
+directory in which filenames returned by \code{mktemp()} reside. The
+default is taken from the environment variable \code{TMPDIR}; if this
+is not set, either \code{/usr/tmp} is used (on UNIX), or the current
+working directory (all other systems). No check is made to see
+whether its value is valid.
+\end{datadesc}
+\ttindex{TMPDIR}
+
+\begin{datadesc}{template}
+When set to a value other than \code{None}, this variable defines the
+prefix of the final component of the filenames returned by
+\code{mktemp()}. A string of decimal digits is added to generate
+unique filenames. The default is either ``\code{@\var{pid}.}'' where
+\var{pid} is the current process ID (on UNIX), or ``\code{tmp}'' (all
+other systems).
+\end{datadesc}
+
+Warning: if a UNIX process uses \code{mktemp()}, then calls
+\code{fork()} and both parent and child continue to use
+\code{mktemp()}, the processes will generate conflicting temporary
+names. To resolve this, the child process should assign \code{None}
+to \code{template}, to force recomputing the default on the next call
+to \code{mktemp()}.