]> Dogcows Code - chaz/openbox/blobdiff - openbox/openbox.c
make ob_exit() take an error code. don't exit with 0 for signals other than TERM...
[chaz/openbox] / openbox / openbox.c
index a8102c3ad582dc88c837bc7a64c5c0cb42ba1bd6..5b7e8e7e69c3090615ffe3dd233256d1c2599803 100644 (file)
@@ -61,6 +61,7 @@ static gboolean  restart;
 static char     *restart_path;
 static Cursor    cursors[OB_NUM_CURSORS];
 static KeyCode   keys[OB_NUM_KEYS];
+static gint      exitcode = 0;
 
 static void signal_handler(int signal, gpointer data);
 static void parse_args(int argc, char **argv);
@@ -211,13 +212,13 @@ int main(int argc, char **argv)
                 }
             }
             event_startup(reconfigure);
-            grab_startup(reconfigure);
             /* focus_backup is used for stacking, so this needs to come before
                anything that calls stacking_add */
             focus_startup(reconfigure);
             window_startup(reconfigure);
             sn_startup(reconfigure);
             screen_startup(reconfigure);
+            grab_startup(reconfigure);
             group_startup(reconfigure);
             client_startup(reconfigure);
             dock_startup(reconfigure);
@@ -257,11 +258,11 @@ int main(int argc, char **argv)
             dock_shutdown(reconfigure);
             client_shutdown(reconfigure);
             group_shutdown(reconfigure);
+            grab_shutdown(reconfigure);
             screen_shutdown(reconfigure);
             focus_shutdown(reconfigure);
             sn_shutdown(reconfigure);
             window_shutdown(reconfigure);
-            grab_shutdown(reconfigure);
             event_shutdown(reconfigure);
             config_shutdown();
         } while (reconfigure);
@@ -297,7 +298,7 @@ int main(int argc, char **argv)
         execlp(argv[0], g_path_get_basename(argv[0])); /* last resort */
     }
      
-    return 0;
+    return exitcode;
 }
 
 static void signal_handler(int signal, gpointer data)
@@ -310,7 +311,8 @@ static void signal_handler(int signal, gpointer data)
         ob_reconfigure();
     } else {
        fprintf(stderr, "Caught signal %d. Exiting.\n", signal);
-        ob_exit();
+        /* TERM and INT return a 0 code */
+        ob_exit(!(signal == SIGTERM || signal == SIGINT));
     }
 }
 
@@ -386,17 +388,18 @@ void ob_restart_other(const gchar *path)
 void ob_restart()
 {
     restart = TRUE;
-    ob_exit();
+    ob_exit(0);
 }
 
 void ob_reconfigure()
 {
     reconfigure = TRUE;
-    ob_exit();
+    ob_exit(0);
 }
 
-void ob_exit()
+void ob_exit(gint code)
 {
+    exitcode = code;
     ob_main_loop_exit(ob_main_loop);
 }
 
This page took 0.024467 seconds and 4 git commands to generate.