]> git.lizzy.rs Git - bspwm.git/blobdiff - src/bspwm.c
Set CLOEXEC on the sockets except when restarting
[bspwm.git] / src / bspwm.c
index dca03fdea238a2975da5239830882564eec0a69c..9c6be76c82972e5e5656a736b70003f6d85b679b 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/wait.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <fcntl.h>
 #include <signal.h>
 #include <unistd.h>
 #include <stdbool.h>
@@ -190,6 +191,8 @@ int main(int argc, char *argv[])
                }
        }
 
+       fcntl(sock_fd, F_SETFD, FD_CLOEXEC | fcntl(sock_fd, F_GETFD));
+
        signal(SIGINT, sig_handler);
        signal(SIGHUP, sig_handler);
        signal(SIGTERM, sig_handler);
@@ -282,6 +285,8 @@ int main(int argc, char *argv[])
        xcb_disconnect(dpy);
 
        if (restart) {
+               fcntl(sock_fd, F_SETFD, ~FD_CLOEXEC & fcntl(sock_fd, F_GETFD));
+
                int rargc;
                for (rargc = 0; rargc < argc; rargc++) {
                        if (streq("-s", argv[rargc])) {