瀏覽代碼

Exit GRASS from GUI (see https://trac.osgeo.org/grass/changeset/66917) - implement also for g.gui

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66918 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 年之前
父節點
當前提交
052b5e7060
共有 2 個文件被更改,包括 10 次插入5 次删除
  1. 7 5
      general/g.gui/main.c
  2. 3 0
      lib/init/grass.py

+ 7 - 5
general/g.gui/main.c

@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
     struct Option *type, *rc_file;
     struct Flag *update_ui, *fglaunch, *nolaunch;
     struct GModule *module;
-    const char *gui_type_env;
+    const char *gui_type_env, *shell_pid;
     char progname[GPATH_MAX];
     char *desc;
 
@@ -103,6 +103,8 @@ int main(int argc, char *argv[])
 	exit(EXIT_SUCCESS);
     }
 
+    shell_pid = G_getenv_nofatal("PID");
+    
     sprintf(progname, "%s/gui/wxpython/wxgui.py", G_gisbase());
     if (access(progname, F_OK) == -1)
         G_fatal_error(_("Your installation doesn't include GUI, exiting."));
@@ -111,22 +113,22 @@ int main(int argc, char *argv[])
         G_message(_("Launching <%s> GUI, please wait..."), type->answer);
         if (rc_file->answer) {
             G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-                       "--workspace", rc_file->answer, NULL);
+                       "--workspace", rc_file->answer, "--pid", shell_pid, NULL);
         }
         else {
             G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-                       NULL);
+                       "--pid", shell_pid, NULL);
         }
     }
     else {
         G_message(_("Launching <%s> GUI in the background, please wait..."), type->answer);
         if (rc_file->answer) {
             G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-                       "--workspace", rc_file->answer, SF_BACKGROUND, NULL);
+                       "--workspace", rc_file->answer, "--pid", shell_pid, SF_BACKGROUND, NULL);
         }
         else {
             G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-                       SF_BACKGROUND, NULL);
+                       "--pid", shell_pid, SF_BACKGROUND, NULL);
         }
         /* stop the impatient from starting it again
            before the splash screen comes up */

+ 3 - 0
lib/init/grass.py

@@ -1901,6 +1901,9 @@ def main():
                                             mapset_settings.location)
 
         start_gui(grass_gui, shell_process.pid)
+        kv = read_gisrc(gisrc)
+        kv['PID'] = str(shell_process.pid)
+        write_gisrc(kv, gisrc)
         exit_val = shell_process.wait()
         if exit_val != 0:
             warning(_("Failed to start shell '%s'") % os.getenv('SHELL'))