[GRASS-dev] G_tempfile() proposed changes [relevant to creating
a new location]
Glynn Clements
glynn at gclements.plus.com
Mon Jan 8 09:04:00 EST 2007
Paul Kelly wrote:
> > For #3, it would help if we used a directory which was specific to
> > GRASS (e.g. /tmp/grass-<user>-<session-pid> rather than /tmp) so that
> > we don't have to worry about deleting something we shouldn't.
>
> The issue here I think is (IIRC) that session directory is only created
> when you start a GRASS session from Init.sh, right? So if some external
> program is calling GRASS modules, e.g. QGIS or something (not 100% sure
> how it works) it would have been OK up to now with just a few environment
> variables set - if we make this change there will have to be an official
> GRASS "session" for G_tempfile to work. Unless I've missed something.
G_tempfile() could always create the directory itself if it doesn't
already exist. $GIS_LOCK would still need to be set in order to have a
directory which is specific to a particular session.
> But yes I can't see any other way of easily deleting the temp files
> without accidentally deleting something else.
It has since occurred to me that we could still run into problems due
to PID re-use. Temporary files whose names contain the PID of the
current process could have been created by a previous process with the
same PID with the intent that they persist. The only 100% robust
solution is to store "persistent temporary files" (is that an
oxymoron?) in a different directory to "transient" temporary files.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list