]> git.lizzy.rs Git - bspwm.git/commitdiff
Only handle stdout closure for subscribers
authorBastien Dejean <nihilhill@gmail.com>
Mon, 19 Oct 2020 08:06:41 +0000 (10:06 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Mon, 19 Oct 2020 08:06:41 +0000 (10:06 +0200)
Thanks to @ortango for the patch.

Fixes #1207.

src/bspc.c
src/common.h
src/messages.c

index 5dd807cd0da00ab34fae1d80f4633398f7d168c2..1a99b5acc7a939f7cc39fbafd07b42c89dd02d6b 100644 (file)
@@ -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;
                }
        }
index f44eef88d8148e9307c6fc8457abfdec7cfba908..fa30cb11103147c4d445d782456058dbcbe7052a 100644 (file)
@@ -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
index 9d9f46786893e99aabecf528232d3f87571a692a..f4c7064df2914b2b7ad0d686e174cd0bf8ce82a1 100644 (file)
@@ -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);