From MEC at stowers.org  Tue Apr 25 18:12:43 2017
From: MEC at stowers.org (Cook, Malcolm)
Date: Tue, 25 Apr 2017 16:12:43 +0000
Subject: [Rd] tempdir() may be deleted during long-running R session
In-Reply-To: <CADwqtCMdcpBARji0j=qjxVvCzAn71UA5tHQG3FgE3rOHbofUtQ@mail.gmail.com>
References: <c78e9022-04c2-3cda-5898-dceec8bc5e94@helsinki.fi>
 <15e3b0a3-e0a8-2da8-27c4-9268a5751986@stats.ox.ac.uk>
 <4f0797c5-a078-67ae-3992-cd66a82b454a@helsinki.fi>
 <22777.65060.465733.160015@max.eddelbuettel.com>
 <20170421173446.GB20737@ofb.net>
 <22780.46838.39255.710673@max.eddelbuettel.com>
 <22783.11355.51121.660887@stat.math.ethz.ch>
 <CABFfbXsXXxvF7qAA0F5ERd9rvZMAOce3RRTzd9zquHVeSFDn2g@mail.gmail.com>
 <22783.28939.482139.354035@stat.math.ethz.ch>
 <CADwqtCMdcpBARji0j=qjxVvCzAn71UA5tHQG3FgE3rOHbofUtQ@mail.gmail.com>
Message-ID: <5b9bdc4afa1a48569934571a4b8b87c7@exchsrv2.sgc.loc>

> Martin,
 > 
 > Thanks for your work on this.
 > 
 > One thing that seems to be missing from the conversation is that recreating
 > the temp directory will prevent future failures when R wants to write a
 > temp file, but the files will, of course, not be there. Any code written
 > assuming the contract is that the temporary directory, and thus temporary
 > files, will not be cleaned up before the R process exits (which was my
 > naive assumption before this thread, and is the behavior AFAICT on all the
 > systems I regularly use) will still break.
 > 

That is the kind of scenario I was hoping to obviate with my suggestion...

 > I'm not saying that's necessarily fixable (though the R keeping a permanent
 > pointer to a file in the dir suggested by Malcom might? fix it.), 

(and, FWIW, that's "Malcolm" with two "l"s.  I think all those missing "l"s are flattened out versions of all the extra close parens I typed in the 80s that somehow got lost on the nets...)))

> but I
 > would argue if it IS fixable, a fix that includes that would be preferable.

Agreed!

 > 
 > Best,
 > ~G
 > 
 > On Tue, Apr 25, 2017 at 8:53 AM, Martin Maechler
 > <maechler at stat.math.ethz.ch
 > > wrote:
 > 
 > > >>>>> Jeroen Ooms <jeroenooms at gmail.com>
 > > >>>>>     on Tue, 25 Apr 2017 15:05:51 +0200 writes:
 > >
 > >     > On Tue, Apr 25, 2017 at 1:00 PM, Martin Maechler
 > >     > <maechler at stat.math.ethz.ch> wrote:
 > >     >> As I've found it is not at all hard to add an option
 > >     >> which checks the existence and if the directory is no
 > >     >> longer "valid", tries to recreate it (and if it fails
 > >     >> doing that it calls the famous R_Suicide(), as it does
 > >     >> when R starts up and tempdir() cannot be initialized
 > >     >> correctly).
 > >
 > >     > Perhaps this can also fix the problem with mcparallel
 > >     > deleting the tempdir() when one of its children dies:
 > >
 > >    >   file.exists(tempdir()) #TRUE
 > >    >   parallel::mcparallel(q('no'))
 > >    >   file.exists(tempdir()) # FALSE
 > >
 > > Thank you, Jeroen, for the extra example.
 > >
 > > I now have comitted the new feature... (completely back
 > > compatible: in R's code tempdir() is not yet called with an
 > > argument and the default is  check = FALSE ),
 > > actually in a "suicide-free" way ...  which needed only slightly
 > > more code.
 > >
 > > In the worst case, one could save the R session by
 > >    Sys.setenv(TEMPDIR = "<something writable>")
 > > if for instance /tmp/ suddenly became unwritable for the user.
 > >
 > > What we could consider is making the default of 'check' settable
 > > by an option, and experiment with setting the option to TRUE, so
 > > all such problems would be auto-solved (says the incurable optimist ...).
 > >
 > > Martin
 > >
 > > ______________________________________________
 > > R-devel at r-project.org mailing list
 > > https://stat.ethz.ch/mailman/listinfo/r-devel
 > >
 > 
 > 
 > 
 > --
 > Gabriel Becker, PhD
 > Associate Scientist (Bioinformatics)
 > Genentech Research
 > 
 > 	[[alternative HTML version deleted]]
 > 
 > ______________________________________________
 > R-devel at r-project.org mailing list
 > https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] tempdir() may be deleted during long-running R session
Cook, Malcolm