#include <glib.h>
-#include <avahi-common/util.h>
-#include <avahi-core/llist.h>
+#include <avahi-common/llist.h>
#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
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;
goto fail;
}
- if (avahi_set_cloexec(fd) < 0) {
+ if (set_cloexec(fd) < 0) {
daemon_log(LOG_ERR, "fcntl(): %s", strerror(errno));
goto fail;
}
static void run_script(gboolean new, gint interface, guchar protocol, const gchar *address) {
gchar *p;
- g_assert(interface > 0);
gint ret;
gchar ia[16], pa[16];
gchar name[IFNAMSIZ+1];
+ g_assert(interface > 0);
+
if (!getifname(interface, name, sizeof(name)))
return;
if (daemonize)
daemon_retval_send(0);
-
+
+ ret = 0;
+
while (!quit) {
fd_set rfds, wfds;
}
}
}
-
- ret = 0;
finish:
daemon_signal_done();
+ if (ret != 0 && daemonize)
+ daemon_retval_send(1);
+
return ret;
}