]> git.lizzy.rs Git - bspwm.git/blobdiff - src/subscribe.c
Set CLOEXEC on the sockets except when restarting
[bspwm.git] / src / subscribe.c
index 328ca128e4153691a3c12d55a39b418d7b27d949..494c466e3a520b490daadb617003fe731bf6d2fd 100644 (file)
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <fcntl.h>
 #include "bspwm.h"
 #include "desktop.h"
 #include "settings.h"
@@ -63,7 +64,10 @@ void remove_subscriber(subscriber_list_t *sb)
        if (sb == subscribe_tail) {
                subscribe_tail = a;
        }
-       if (!restart) {
+       if (restart) {
+               int cli_fd = fileno(sb->stream);
+               fcntl(cli_fd, F_SETFD, ~FD_CLOEXEC & fcntl(cli_fd, F_GETFD));
+       } else {
                fclose(sb->stream);
                unlink(sb->fifo_path);
        }
@@ -80,6 +84,8 @@ void add_subscriber(subscriber_list_t *sb)
                sb->prev = subscribe_tail;
                subscribe_tail = sb;
        }
+       int cli_fd = fileno(sb->stream);
+       fcntl(cli_fd, F_SETFD, FD_CLOEXEC | fcntl(cli_fd, F_GETFD));
        if (sb->field & SBSC_MASK_REPORT) {
                print_report(sb->stream);
                if (sb->count-- == 1) {