octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: temporary files not deleted after exit


From: Jaroslav Hajek
Subject: Re: temporary files not deleted after exit
Date: Thu, 26 Aug 2010 07:05:38 +0200

On Wed, Aug 25, 2010 at 10:37 PM, bpabbott <address@hidden> wrote:
> On 25 Aug, 2010,at 04:16 PM, "John W. Eaton" <address@hidden> wrote:
>
> On 25-Aug-2010, Judd Storrs wrote:
>
> | On Wed, Aug 25, 2010 at 3:06 PM, Muhali <address@hidden> wrote:
> |
> | in that case I would not use a temporary name. If none of these files are
> | temporary, what then is a 'temporary' file?
> |
> | Files opened with mkstemp() and tmpfile(), but I don't see anyway to use
> those
> | with save().
>
> Should we have fsave and fload functions that accept file IDs instead of
> names?
>
> | I could have sworn I once came across a function that would add
> | files to the list of files to be deleted on exit, but I can't find
> | it now so I must be hallucinating?
>
> Look at mark_for_deletion in file-io.cc. But it is not exported to
> the interpreter level. Should we do that?
>
> Maybe discussion about these questions would be more appropriate for
> the maintainers list.
>
> jwe
>
>
> I'm guilty of not paying close enough attention to how the temp files work.
> As a result there are several examples in scripts/plot where tmpnam() is
> used, but the file is not deleted.
> Having mark_for_deletion be exported to the interpreter level would make it
> easy to fix that.

Hi Ben,

while this is not a bad idea per se (and actually a mark_for_deletion
wrapper is provided by OctaveForge), I think it would be better if
deleting temporary files occurred as soon as they're not needed (e.g.
at end of function) rather than being deferred to Octave's exit. For
instance, if Octave crashes, the files won't be deleted.
You can use either unwind_protect or onCleanup for the task. If it
occurs often, we could consider a wrapper over fopen that calls fclose
automatically.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]