From: Tony Crisci Date: Fri, 14 Feb 2014 01:17:18 +0000 (-0500) Subject: i3bar: Do not kill watcher on EOF X-Git-Tag: 4.8~115 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=00909aa3b15857aba6894a9a244ece32094ca988;p=i3%2Fi3 i3bar: Do not kill watcher on EOF Wait for the child process to exit on its own before freeing watcher-related resources. i3bar shows the last received status line until the process exits. Fixes a race condition where the termination signal was sometimes not received to display a meaningful error message. --- diff --git a/i3bar/src/child.c b/i3bar/src/child.c index d19192f2..cfdf911c 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -266,6 +266,8 @@ static int stdin_end_array(void *context) { /* * Helper function to read stdin * + * Returns NULL on EOF. + * */ static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) { int fd = watcher->fd; @@ -285,9 +287,7 @@ static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) { exit(EXIT_FAILURE); } if (n == 0) { - /* end of file, kill the watcher */ ELOG("stdin: received EOF\n"); - cleanup(); *ret_buffer_len = -1; return NULL; }