[GRASS-SVN] r39251 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 19 11:46:31 EDT 2009


Author: hamish
Date: 2009-09-19 11:46:30 -0400 (Sat, 19 Sep 2009)
New Revision: 39251

Modified:
   grass/trunk/lib/init/functions.sh
   grass/trunk/lib/init/lock.c
Log:
move lockfile detection to exit(2) to allow G_fatal_error() to occupy exit(1) alone (trac #755)

Modified: grass/trunk/lib/init/functions.sh
===================================================================
--- grass/trunk/lib/init/functions.sh	2009-09-19 15:12:37 UTC (rev 39250)
+++ grass/trunk/lib/init/functions.sh	2009-09-19 15:46:30 UTC (rev 39251)
@@ -507,7 +507,7 @@
     "$ETC/lock" "$lockfile" $$
     case $? in
 	0) ;;
-	1)
+	2)
 	    echo "$USER is currently running GRASS in selected mapset (file $lockfile found). Concurrent use not allowed."
 	    cleanup_tmpdir
 	    exit 1 ;;

Modified: grass/trunk/lib/init/lock.c
===================================================================
--- grass/trunk/lib/init/lock.c	2009-09-19 15:12:37 UTC (rev 39250)
+++ grass/trunk/lib/init/lock.c	2009-09-19 15:46:30 UTC (rev 39251)
@@ -15,8 +15,9 @@
 *
 *   1. if file exists, the pid is read out of the file. if this
 *      process is still running, the file is considered locked.
-*      exit(1)
-*   2. if file does not exist, or if file exists but process is not
+*      exit(2).
+*   2. something weird happened. G_fatal_error() aka exit(1)
+*   3. if file does not exist, or if file exists but process is not
 *      running (ie, lock was not removed), the file is locked for
 *      process pid by writing pid into the file.
 *      exit(0).
@@ -49,7 +50,7 @@
 	close(lock);
     }
     if (locked)
-	exit(1);
+	exit(2);
 
     if ((lock = creat(file, 0666)) < 0) {
 	perror(file);



More information about the grass-commit mailing list