From 204d45df751cfc84133317c88bc6c46e0de12b52 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 22 Aug 2011 11:14:43 -0400 Subject: [PATCH] Set SOCK_CLOEXEC on socket connected to Signed-off-by: Mathieu Desnoyers --- liblttng-sessiond-comm/lttng-sessiond-comm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/liblttng-sessiond-comm/lttng-sessiond-comm.c b/liblttng-sessiond-comm/lttng-sessiond-comm.c index e370fcd3..53e7462b 100644 --- a/liblttng-sessiond-comm/lttng-sessiond-comm.c +++ b/liblttng-sessiond-comm/lttng-sessiond-comm.c @@ -117,7 +117,11 @@ int lttcomm_connect_unix_sock(const char *pathname) int fd; int ret; - fd = socket(PF_UNIX, SOCK_STREAM, 0); + /* + * libust threads require the close-on-exec flag for all + * resources so it does not leak file descriptors upon exec. + */ + fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); if (fd < 0) { perror("socket"); ret = fd; -- 2.34.1