From 9d126a4eda9c3efdd593e63adfd5d2f7dddae18c Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Sun, 19 Feb 2017 16:14:37 -0800 Subject: Cleans up os_daemon() in Windows case. This provides an always-failing os_daemon() for platforms (e.g., Windows) that can't provide a real daemon() call. This is more consistent than simply omitting the function. It also bases the condition on the lack of fork(), rather than the presence of winsock2.h. TESTED: Ran "scons build-all check" on OSX, Linux, FreeBSD, OpenBSD, and NetBSD. Verified that HAVE_FORK is set in all cases. --- os_compat.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'os_compat.c') diff --git a/os_compat.c b/os_compat.c index dafbb7a4..790aaf94 100644 --- a/os_compat.c +++ b/os_compat.c @@ -45,10 +45,10 @@ int clock_gettime(clockid_t clk_id, struct timespec *ts) /* End of clock_gettime section */ #ifndef HAVE_DAEMON -#ifndef HAVE_WINSOCK2_H -/* No daemon() provided for Windows as not currently needed */ /* Simulate Linux/BSD daemon() on platforms that don't have it */ +#ifdef HAVE_FORK + #include #include #include @@ -91,7 +91,19 @@ int os_daemon(int nochdir, int noclose) /* coverity[leaked_handle] Intentional handle duplication */ return 0; } -#endif /* HAVE_WINSOCK2_H */ +#else /* !HAVE_FORK */ + +#include + +int os_daemon(int nochdir, int noclose) +{ + (void) nochdir; (void) noclose; + errno = EINVAL; + return -1; +} + +#endif /* !HAVE_FORK */ + #else /* HAVE_DAEMON */ #ifdef __linux__ -- cgit v1.2.1