Pārlūkot izejas kodu

move lockfile detection to exit(2) to allow G_fatal_error() to occupy exit(1) alone (trac https://trac.osgeo.org/grass/ticket/755)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39251 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 16 gadi atpakaļ
vecāks
revīzija
1f86ff433d
2 mainītis faili ar 5 papildinājumiem un 4 dzēšanām
  1. 1 1
      lib/init/functions.sh
  2. 4 3
      lib/init/lock.c

+ 1 - 1
lib/init/functions.sh

@@ -507,7 +507,7 @@ check_lock()
     "$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 ;;

+ 4 - 3
lib/init/lock.c

@@ -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 @@ int main(int argc, char *argv[])
 	close(lock);
     }
     if (locked)
-	exit(1);
+	exit(2);
 
     if ((lock = creat(file, 0666)) < 0) {
 	perror(file);