]> Dogcows Code - chaz/openbox/blobdiff - openbox/openbox.c
dont have glib reap children, we shall reap them instead to avoid zombies from proces...
[chaz/openbox] / openbox / openbox.c
index 7c68e2a5d93b9bcbcbf357f88b5e7ab450295365..ef3f8ac533f450f427fa808932c9b7ff641b7591 100644 (file)
 #  include <sys/stat.h>
 #  include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_WAIT_H
+#  include <sys/types.h>
+#  include <sys/wait.h>
+#endif
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>
 #endif
+#include <errno.h>
 
 #include <X11/cursorfont.h>
 
@@ -101,7 +106,9 @@ gint main(gint argc, gchar **argv)
 
     g_set_prgname(argv[0]);
 
-    chdir(g_get_home_dir());
+    if (chdir(g_get_home_dir()) == -1)
+        g_warning("Unable to change to home directory (%s): %s",
+                  g_get_home_dir(), g_strerror(errno));
      
     parse_paths_startup();
 
@@ -125,6 +132,7 @@ gint main(gint argc, gchar **argv)
     ob_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL, NULL);
     ob_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL, NULL);
     ob_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL, NULL);
+    ob_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL, NULL);
 
     ob_screen = DefaultScreen(ob_display);
 
@@ -311,6 +319,7 @@ gint main(gint argc, gchar **argv)
             } else {
                 g_warning("failed to execute '%s': %s", restart_path,
                           err->message);
+                g_error_free(err);
             }
         }
 
@@ -324,13 +333,20 @@ gint main(gint argc, gchar **argv)
 
 static void signal_handler(gint signal, gpointer data)
 {
-    if (signal == SIGUSR1) {
+    switch (signal) {
+    case SIGUSR1:
         ob_debug("Caught signal %d. Restarting.\n", signal);
         ob_restart();
-    } else if (signal == SIGUSR2) {
+        break;
+    case SIGUSR2:
         ob_debug("Caught signal %d. Reconfiguring.\n", signal);
-        ob_reconfigure();
-    } else {
+        ob_reconfigure(); 
+        break;
+    case SIGCHLD:
+        /* reap children */
+        while (waitpid(-1, NULL, WNOHANG) > 0);
+        break;
+    default:
         ob_debug("Caught signal %d. Exiting.\n", signal);
         /* TERM and INT return a 0 code */
         ob_exit(!(signal == SIGTERM || signal == SIGINT));
This page took 0.023184 seconds and 4 git commands to generate.