diff --git a/sway/ipc.c b/sway/ipc.c index a6c4eb1ac..69f4a4f38 100644 --- a/sway/ipc.c +++ b/sway/ipc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "ipc.h" #include "log.h" #include "config.h" @@ -78,6 +79,12 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) { return 0; } + int flags; + if ((flags=fcntl(client_fd, F_GETFD)) == -1 || fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) { + sway_log_errno(L_INFO, "Unable to set CLOEXEC on IPC client socket"); + return 0; + } + struct ipc_client* client = malloc(sizeof(struct ipc_client)); client->payload_length = 0; client->fd = client_fd;