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

frederik at ofb.net frederik at ofb.net
Wed Apr 26 06:13:59 CEST 2017


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



More information about the R-devel mailing list