[GRASSLIST:4586] Re: .tmp files
Christoph Hoegl
C.Hoegl at gmx.net
Wed Sep 25 17:49:02 EDT 2002
Hi all,
why not implement a rather easy method involving a lock file?
grass tasks could create
first a lock file called $tempname.lock containing the pid of the creating
program,
second the $temp_dir temporary directory
after work is done the $temp_dir and afterwards the $tempname.lock file
are unlinked.
If manage_a_lock.sh dies then there will be no program using the pid resulting
in deletion of the $tempname.lock as well as the $temp_dir, or better
have it live a grace period that is checked by a cronjob
(this applies only if the pid wraparound time is long enough)
The actual deletion of the $temp_dir and lock files as well as the creation of
them could be managed by a shell wrapper (pretty easy but a bit of agreement
on the side of core developers would be nice):
example pseudo code:
before:
v.r.sth args # process creating a tempfile
after
manage_a_lock.sh v.r.sth args
with manage_a_lock.sh looking like this (pseudo again):
create_temp_dir
create_temp_dir.lock
run_grass_task in $temp_dir
if status of job == error keep files and send a message
else delete $temp_dir $temp_dir.lock
send message of job completion
this could of course be implemented in each command creating a tempfile
(and is by design the better solution but while testing the idea a shell
wrapper is doing enough)
There are some caveats though:
Are all commands writing to a tempdirectory which may be given
as a variable (like $GRASS_TEMP)?
What is the best strategy to implement it into library code
so transition/portability is provided for module authors?
regards,
Christoph
--
Christoph Hoegl / C.Hoegl at gmx.net
=> OOOOOOOOOOOOOO = Now in the "TUNNEL IN NO TIME"-team = OOOOOOOOOOOOOOO =>
More information about the grass-user
mailing list