From fa1b436fca50077b7d3446e5e49e48f50d88a5cb Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 14 Apr 2013 10:12:21 +0200 Subject: [PATCH] Bugfix: mark IPC fd CLOEXEC (Thanks Layus) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this fix, children of i3bar would inherit the file descriptor of the IPC connection to i3. Therefore, even if i3bar exits with SIGSEGV, the connection to i3 stays open. Because nobody actually reads any messages by i3, the buffer will fill up and i3 can’t deliver any more messages, and thus busy-loops at that point. fixes #995 --- libi3/ipc_connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libi3/ipc_connect.c b/libi3/ipc_connect.c index 44ff7056..d27e0467 100644 --- a/libi3/ipc_connect.c +++ b/libi3/ipc_connect.c @@ -2,7 +2,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) * */ #include @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "libi3.h" @@ -24,6 +26,8 @@ int ipc_connect(const char *socket_path) { if (sockfd == -1) err(EXIT_FAILURE, "Could not create socket"); + (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC); + struct sockaddr_un addr; memset(&addr, 0, sizeof(struct sockaddr_un)); addr.sun_family = AF_LOCAL;