From frederik at ofb.net  Wed Apr 26 06:13:59 2017
From: frederik at ofb.net (frederik at ofb.net)
Date: Tue, 25 Apr 2017 21:13:59 -0700
Subject: [Rd] tempdir() may be deleted during long-running R session
In-Reply-To: <ea6a1fb2067a4c98b113c878789faf9f@exchsrv2.sgc.loc>
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>
 <ea6a1fb2067a4c98b113c878789faf9f@exchsrv2.sgc.loc>
Message-ID: <20170426041358.GD20737@ofb.net>

On Tue, Apr 25, 2017 at 02:41:58PM +0000, Cook, Malcolm wrote:
> Might this combination serve the purpose: 
> 	* R session keeps an open handle on the tempdir it creates, 
> 	* whatever tempdir harvesting cron job the user has be made sensitive enough not to delete open files (including open directories)

Good suggestion but doesn't work with the (increasingly popular)
"Systemd":

    $ mkdir /tmp/somedir
    $ touch -d "12 days ago" /tmp/somedir/
    $ cd /tmp/somedir/
    $ sudo systemd-tmpfiles --clean
    $ ls /tmp/somedir/
    ls: cannot access '/tmp/somedir/': No such file or directory

I would advocate just changing 'tempfile()' so that it recreates the
directory where the file is (the "dirname") before returning the file
path. This would have fixed the issue I ran into. Changing 'tempdir()'
to recreate the directory is another option.

Thanks,

Frederick



[Rd] tempdir() may be deleted during long-running R session
frederik at ofb.net