From 7aca1b6c4e550c1a5a5cea5cb20d9dd8d3190999 Mon Sep 17 00:00:00 2001 From: Bastien Dejean Date: Mon, 19 Oct 2020 10:06:41 +0200 Subject: [PATCH] Only handle stdout closure for subscribers Thanks to @ortango for the patch. Fixes #1207. --- src/bspc.c | 5 ++++- src/common.h | 3 ++- src/messages.c | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bspc.c b/src/bspc.c index 5dd807c..1a99b5a 100644 --- a/src/bspc.c +++ b/src/bspc.c @@ -79,6 +79,7 @@ int main(int argc, char *argv[]) } int ret = EXIT_SUCCESS, nb; + bool subwait = false; struct pollfd fds[] = { {sock_fd, POLLIN, 0}, @@ -93,6 +94,8 @@ int main(int argc, char *argv[]) ret = EXIT_FAILURE; fprintf(stderr, "%s", rsp + 1); fflush(stderr); + } else if (rsp[0] == SUBSCRIBE_MESSAGE[0]) { + subwait = true; } else { fprintf(stdout, "%s", rsp); fflush(stdout); @@ -101,7 +104,7 @@ int main(int argc, char *argv[]) break; } } - if (fds[1].revents & (POLLERR | POLLHUP)) { + if (subwait && fds[1].revents & (POLLERR | POLLHUP)) { break; } } diff --git a/src/common.h b/src/common.h index f44eef8..fa30cb1 100644 --- a/src/common.h +++ b/src/common.h @@ -28,6 +28,7 @@ #define SOCKET_PATH_TPL "/tmp/bspwm%s_%i_%i-socket" #define SOCKET_ENV_VAR "BSPWM_SOCKET" -#define FAILURE_MESSAGE "\x07" +#define FAILURE_MESSAGE "\x07" +#define SUBSCRIBE_MESSAGE "\x08" #endif diff --git a/src/messages.c b/src/messages.c index 9d9f467..f4c7064 100644 --- a/src/messages.c +++ b/src/messages.c @@ -1332,6 +1332,9 @@ void cmd_subscribe(char **args, int num, FILE *rsp) perror("subscribe: fopen"); goto free_fifo_path; } + } else { + fprintf(rsp, SUBSCRIBE_MESSAGE); + fflush(rsp); } subscriber_list_t *sb = make_subscriber(stream, fifo_path, field, count); -- 2.44.0