all repos — openbox @ 745e851faa0a6f83858ef064ca589a33497e0b5a

openbox fork - make it a bit more like ryudo

dont have glib reap children, we shall reap them instead to avoid zombies from processes tranferred to us
Dana Jansens danakj@orodu.net
commit

745e851faa0a6f83858ef064ca589a33497e0b5a

parent

05c1f333238ba2eccf22f334072cb653c0d64957

2 files changed, 27 insertions(+), 6 deletions(-)

jump to
M openbox/action.copenbox/action.c

@@ -979,14 +979,23 @@

void action_execute(union ActionData *data) { GError *e = NULL; - gchar *cmd; + gchar *cmd, **argv = 0; if (data->execute.path) { cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL); if (cmd) { - if (!g_spawn_command_line_async(cmd, &e)) { + if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) { g_warning("failed to execute '%s': %s", cmd, e->message); g_error_free(e); + } else { + if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, NULL, &e)) { + g_warning("failed to execute '%s': %s", + cmd, e->message); + g_error_free(e); + } + g_strfreev(argv); } g_free(cmd); } else {
M openbox/openbox.copenbox/openbox.c

@@ -59,6 +59,10 @@ #ifdef HAVE_SYS_STAT_H

# 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

@@ -128,6 +132,7 @@ ob_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL, NULL);

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 @@ }

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));