[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PSPP-BUG: Usage of tmpfile() vs. getenv("TMPDIR")
From: |
Jan Steemann |
Subject: |
PSPP-BUG: Usage of tmpfile() vs. getenv("TMPDIR") |
Date: |
Thu, 8 Apr 2010 09:21:43 +0200 |
Hi everybody,
the PSPP command line binary may create a few temporary files during data
processing.
As far as I can see, pspp uses the TMPDIR environment variable (it uses
getenv("TMPDIR") and uses the result when available) to determine the directory
for temporary files. That means the directory for temporary files can be
configured at runtime when invoking the pspp binary.
This is fine, however, I think pspp also uses the POSIX tmpfile() call in some
cases. tmpfile() does not seem to use the TMPDIR environment variable and as
far as I can see it is not fully portable nor is its result predictable.
The tmpfile man page says:
"The standard does not specify the directory that tmpfile() will use. Glibc
will try the path prefix P_tmpdir defined in <stdio.h>, and if that fails the
directory /tmp.".
P_tmpdir is a compile time definition whereas reading an environment variable
is a runtime configuration.
P_tmpdir defaults to "/tmp" in my enviroment (which is the system's temporary
directory). That means pspp will create a few temporary files in /tmp, however,
it creates several other files in /opt/pdp/tmp (which is the directory
specified using the $TMPDIR environment variable).
That means when invoking pspp from the command line the temporary files may go
to two different directories which is not very good when trying to control,
monitor, and limit disk usage.
While tmpfile() is definitely convenient to use in the code, I think the calls
should be changed to use some procedure that uses the TMPDIR environment
variable (when available) and creates the temporary files there. Additionally,
the temporary files would need to be removed when not required anymore.
tmpfile() does that automatically but any other procedures won't.
In pspp-0.6.1, I found the following usages of tmpfile():
src/data/case-tmpfile.c:54: ctf->file = tmpfile ();
src/libpspp/pool.c:754: FILE *file = tmpfile ();
src/output/postscript.c:1096: ch->file = tmpfile ();
I saw there is a more recent version of pspp already, however, the newer
version still uses tmpfile().
Do you think the tmpfile() calls can be changed?
Thank you and best regards
Jan
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- PSPP-BUG: Usage of tmpfile() vs. getenv("TMPDIR"),
Jan Steemann <=