summaryrefslogtreecommitdiffstats
path: root/avahi-dnsconfd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-12 00:28:17 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-12 00:28:17 +0000
commit66c6bca0849a82be92d6bff82c478d769f8af869 (patch)
tree996d476699fc52683de6a267003ec6630f94a351 /avahi-dnsconfd
parent5ebf655c85076f200955458673a8bbf0dd927407 (diff)
fix avahi-dnsconfd.c
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@300 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-dnsconfd')
-rw-r--r--avahi-dnsconfd/main.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/avahi-dnsconfd/main.c b/avahi-dnsconfd/main.c
index 90cd55c..99bae64 100644
--- a/avahi-dnsconfd/main.c
+++ b/avahi-dnsconfd/main.c
@@ -115,6 +115,20 @@ static DNSServerInfo* new_server_info(gint interface, guchar protocol, const gch
return i;
}
+static int set_cloexec(int fd) {
+ int n;
+
+ assert(fd >= 0);
+
+ if ((n = fcntl(fd, F_GETFD)) < 0)
+ return -1;
+
+ if (n & FD_CLOEXEC)
+ return 0;
+
+ return fcntl(fd, F_SETFD, n|FD_CLOEXEC);
+}
+
static int open_socket(void) {
int fd = -1;
struct sockaddr_un sa;
@@ -124,7 +138,7 @@ static int open_socket(void) {
goto fail;
}
- if (avahi_set_cloexec(fd) < 0) {
+ if (set_cloexec(fd) < 0) {
daemon_log(LOG_ERR, "fcntl(): %s", strerror(errno));
goto fail;
}