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.
This commit is contained in:
parent
759c26fc02
commit
00909aa3b1
|
@ -266,6 +266,8 @@ static int stdin_end_array(void *context) {
|
||||||
/*
|
/*
|
||||||
* Helper function to read stdin
|
* Helper function to read stdin
|
||||||
*
|
*
|
||||||
|
* Returns NULL on EOF.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) {
|
static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) {
|
||||||
int fd = watcher->fd;
|
int fd = watcher->fd;
|
||||||
|
@ -285,9 +287,7 @@ static unsigned char *get_buffer(ev_io *watcher, int *ret_buffer_len) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
/* end of file, kill the watcher */
|
|
||||||
ELOG("stdin: received EOF\n");
|
ELOG("stdin: received EOF\n");
|
||||||
cleanup();
|
|
||||||
*ret_buffer_len = -1;
|
*ret_buffer_len = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue