From 543a57f8aff2fb7b5f02af685ff501130b8e0075 Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Tue, 18 Nov 2014 09:21:42 +0100 Subject: [PATCH] prevent going through systemd/upstart code, except on Linux Fixes #809 (build issue on MacOSX) NB: in case one day upstart is used on non-Linux platforms, this could be relaxed to only skip systemd. --- src/daemon/collectd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 309af1ba..1b9c3747 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -414,6 +414,7 @@ static int pidfile_remove (void) } /* static int pidfile_remove (const char *file) */ #endif /* COLLECT_DAEMON */ +#ifdef KERNEL_LINUX int notify_upstart (void) { const char *upstart_job = getenv("UPSTART_JOB"); @@ -479,6 +480,7 @@ int notify_systemd (void) close(fd); return 1; } +#endif /* KERNEL_LINUX */ int main (int argc, char **argv) { @@ -598,9 +600,13 @@ int main (int argc, char **argv) /* * Only daemonize if we're not being supervised - * by upstart or systemd. + * by upstart or systemd (when using Linux). */ - if (daemonize && notify_upstart() == 0 && notify_systemd() == 0) + if (daemonize +#ifdef KERNEL_LINUX + && notify_upstart() == 0 && notify_systemd() == 0 +#endif + ) { if ((pid = fork ()) == -1) { -- 2.11.0