[GRASS5] Files left in /tmp from Init.sh
Juillerat Philippe
philippe.juillerat at net2000.ch
Mon Feb 7 05:47:55 EST 2005
Hi
I noticed since I use GRASS 5.7 and also GRASS 6.0 cvs 2 problems (linked)
that I don't have with GRASS 5.4
PROBLEM 1
A large number of temporary directories and files are left in the /tmp
directory
PROBLEM 2
The MAPSET and LOCATION, when defined for a session, are not saved
in .grassrc6 for a next session.
I realized that the problem was linked to the way I exit GRASS (I click the
GRASS shell-window away and usually don't use the exit command) and to the
etc/Init.sh file. The same problem appears when GRASS exit abnormally ex:
grass60 /nonexistentlocation/mapset
PROPOSAL OF SOLUTION
Works fine on mandrake 10.1 with grass 6.0 beta2, as I am a biologist and not
a real developer, you should look at this proposal carefuly :)
The changes are placed between #ooooooooooooooooo.
In order not to send a too long file I cut bin/init.sh at several places
indicated with [...].
If it is not the right way to do, tell me, I will do otherwise next time.
Philippe Juillerat
#! /bin/sh
#############################################################################
#
# $Id: init.sh,v 1.58 2005/02/03 02:24:42 hamish Exp $
#
# MODULE: GRASS Initialization
[...]
(umask 077 && mkdir "$tmp") || {
echo "Cannot create temporary directory! Exiting." 1>&2
exit 1
}
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# remove temporary directory and session files from tmpdir when exiting
trap "rm -rf $tmp" 0
# trapping signal SIGHUP give the opportunity to exit by clicking the
# GRASS shell-window
trap "echo 'User break!' ; exit" 1 2 3 15
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
GISRC="$tmp/gisrc"
export GISRC
[...]
# Check for concurrent use
lockfile="$LOCATION/.gislock"
"$ETC/lock" "$lockfile" $$
case $? in
0) ;;
1)
echo `whoami` is currently running GRASS in selected mapset. Concurrent
use not allowed.
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# rm -rf "$tmp" # Have to be removed since already included
# in trap command above
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
exit 1 ;;
*)
echo Unable to properly access "$lockfile"
echo Please notify system personel.
exit 1 ;;
esac
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# Save $GISRC and remove session files from tmpdir when exiting with the
# terminal window's close button
trap "cp $GISRC $GISRCRC ; exit" 1
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
trap "" 2 3 15
CYGWIN=`uname | grep CYGWIN`
[...]
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# all specified signals are are reset to their original values
trap 0 1 2 3 15
#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# GRASS session finished
tput clear
echo "Closing monitors....."
for MON in `d.mon -L | grep running | grep -v "not running" | sed 's/ .*//'`
do
echo d.mon stop=$MON
d.mon stop=$MON
done
echo "Cleaning up temporary files....."
"$ETC/clean_temp" > /dev/null
rm -f "$lockfile"
# Save GISRC
cp "$GISRC" "$GISRCRC"
rm -rf "$tmp" # remove session files from tmpdir
echo "done"
echo
echo
echo
echo "Goodbye from GRASS GIS"
echo
More information about the grass-dev
mailing list