From 4098c23060bcf75ecf2662be5a7edc21da93c794 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 20 Feb 2014 16:31:53 +0000 Subject: [PATCH] Set cloexec flag to sockets obtained from systemd. --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index a8196ef06..ba091a7f0 100644 --- a/src/main.c +++ b/src/main.c @@ -552,7 +552,7 @@ create_listen_socket (const gchar *addr, gint port, gint listen_type) static GList * systemd_get_socket (gint number, gint listen_type) { - int sock, max; + int sock, max, flags; GList *result = NULL; const gchar *e; gchar *err; @@ -578,6 +578,10 @@ systemd_get_socket (gint number, gint listen_type) return NULL; } } + flags = fcntl (sock, F_GETFD); + if (flags != -1) { + (void)fcntl (sock, F_SETFD, flags | FD_CLOEXEC); + } result = g_list_prepend (result, GINT_TO_POINTER (sock)); } else if (max <= number + sd_listen_fds_start) { -- 2.39.5