X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fopenbox.c;h=ef3f8ac533f450f427fa808932c9b7ff641b7591;hb=745e851faa0a6f83858ef064ca589a33497e0b5a;hp=b688296516911f2afee8254577a00635c3d60d4c;hpb=4cb183401cc42f61a759b02f1210a3528f7869e5;p=chaz%2Fopenbox diff --git a/openbox/openbox.c b/openbox/openbox.c index b6882965..ef3f8ac5 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -59,6 +59,10 @@ # include # include #endif +#ifdef HAVE_SYS_WAIT_H +# include +# include +#endif #ifdef HAVE_UNISTD_H # include #endif @@ -128,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); @@ -328,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));