Re: return to the begin of InputStream
On Sat, 5 Dec 2009, Eric Sosman wrote:
Martin Gregorie wrote:
On Sat, 05 Dec 2009 10:11:30 +0000, Tom Anderson wrote:
However, by default, createTempFile puts files in java.io.tmpdir, which
on unix machines will typically be /tmp. Files there are subject to
deletion at the whim of the OS, so to an extent, you can delegate the
problem of worrying about deleting files to that.
You should attempt to delete them at some stage because there's no
guarantee that the OS will. Its merely a way of guaranteeing that the
tempfile has a unique name no matter how many copies of the process are
running.
(Marginally topical) On Solaris, the Unix flavor I'm most familiar
with, /tmp is usually mounted on a tmpfs file system. This is a
memory-resident file system to the extent possible, spilling over into
swap space as needed. Nothing special needs to happen at reboot to
"clean out" tmpfs, no more than anything special needs to happen to
"clean out" swap files: The newly- booted system just initializes its
metadata to say "empty," and everything from prior incarnations is gone.
Aha, interesting. Seems like a good scheme.
Also, it's a *very* bad idea to purge /tmp blindly, even if you're
careful only to purge files that haven't been modified in a while. I
recall working with a server application that put files in /tmp and
mmap'ed them to share memory between its multiple processes. Since
simple paging I/O to and from a file opened a week ago doesn't change
the files' modification date, along came the customer's /tmp-purging
cron job and BLOOEY went the server ...
Hang on, the files were open, right? So how could they be deleted? Or is
the point that the directory entries were deleted, so when new processes
were spawned, they couldn't open the file? And since when did writing to a
file via an mmap not change its modification time, anyway?
Either way, i'd suggest the bad idea here was putting critical long-lived
files in /tmp. Yes, they're temporary, but not that temporary!
tom
--
an optical recording release. copyright digitally mastered. .,