From: Florian Forster Date: Wed, 6 Feb 2019 14:47:00 +0000 (+0100) Subject: write_prometheus plugin: Only use SOCK_CLOEXEC if it is defined. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ff780ec90d561d7f50bb17c355aaaa5d072d5672;p=collectd.git write_prometheus plugin: Only use SOCK_CLOEXEC if it is defined. Fixes compilation issue on Mac OS X. See also #3055. --- diff --git a/src/write_prometheus.c b/src/write_prometheus.c index ba186a7e..572ba561 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -760,7 +760,12 @@ static int prom_open_socket(int addrfamily) { int fd = -1; for (struct addrinfo *ai = res; ai != NULL; ai = ai->ai_next) { - fd = socket(ai->ai_family, ai->ai_socktype | SOCK_CLOEXEC, 0); + int flags = ai->ai_socktype; +#ifdef SOCK_CLOEXEC + flags |= SOCK_CLOEXEC; +#endif + + fd = socket(ai->ai_family, flags, 0); if (fd == -1) continue;