From: Axel Wagner Date: Mon, 14 Mar 2011 08:17:06 +0000 (+0100) Subject: Bugfix: Don't segfault, if child was killed X-Git-Tag: 4.0.1~7^2~3^2~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dfd566511e4d374807e3dfd4c69c506004c3af13;p=i3%2Fi3 Bugfix: Don't segfault, if child was killed --- diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 795a10d3..890dce29 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -35,11 +36,13 @@ char *statusline_buffer = NULL; * */ void cleanup() { - ev_io_stop(main_loop, stdin_io); - ev_child_stop(main_loop, child_sig); - FREE(stdin_io); - FREE(child_sig); - FREE(statusline_buffer); + if (stdin_io != NULL) { + ev_io_stop(main_loop, stdin_io); + ev_child_stop(main_loop, child_sig); + FREE(stdin_io); + FREE(child_sig); + FREE(statusline_buffer); + } } /* @@ -174,8 +177,11 @@ void kill_child() { if (child_pid != 0) { kill(child_pid, SIGCONT); kill(child_pid, SIGTERM); + int status; + waitpid(child_pid, &status, 0); + child_pid = 0; + cleanup(); } - cleanup(); } /*