reliable temporary file removal

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.core
Message-ID <Pine.GSO.4.44.0303221509270.14868-100000@scooby.simplesystems.org>
ImageMagick (and also GraphicsMagick) tends to leave temporary files
(sometimes very large) in the system's temporary file directory when
the program exits unexpectedly.  This is because it is necessary to
destroy all the existing Images in order to recover the resources they
are using.

I am thinking that besides operating system specific tricks like
removing the file once it is open (Unix) or supplying the _O_TEMPORARY
argument to open() (Windows), all of which seem to cause
implementation problems, a good solution is to add a temporary file
manager.  Temporary files would be "allocated" and are expected to be
returned to the allocator for removal. If GraphicsMagick should get
into a panic situation, or an odd error case, then the temporary files
would still be removed by an exit/signal handler since the list of
temporary files to be removed would be available.

If the program is killed using an uncatchable signal, then temporary
files would still exist unless a reliable operating system specific
mechanism is also used.

Another situation which sometimes occurs is that a coder experiences a
failure/error while writing an output file but dos not remove the
corrupt output file.  It would be good to implement a way to ensure
that these incomplete output files are automatically removed so they
don't cause problems later on.

Bob
======================================
Bob Friesenhahn
[email protected]
http://www.simplesystems.org/users/bfriesen



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.