From d25bd327aec086cb86b39e611d65742eada9b4a4 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Tue, 8 Sep 2015 16:11:56 +0200 Subject: [PATCH] notify_systemd: use close-on-exit on socket --- src/daemon/collectd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 58325b95..02fd66f8 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -459,7 +459,11 @@ int notify_systemd (void) unsetenv ("NOTIFY_SOCKET"); +#if defined(SOCK_CLOEXEC) + fd = socket (AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, /* protocol = */ 0); +#else fd = socket (AF_UNIX, SOCK_DGRAM, /* protocol = */ 0); +#endif if (fd < 0) { char errbuf[1024]; ERROR ("creating UNIX socket failed: %s", -- 2.11.0