summaryrefslogtreecommitdiff
path: root/os_compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'os_compat.c')
-rw-r--r--os_compat.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/os_compat.c b/os_compat.c
index 4ffefb08..b110f4ba 100644
--- a/os_compat.c
+++ b/os_compat.c
@@ -62,7 +62,7 @@ int clock_gettime(clockid_t clk_id, struct timespec *ts)
#endif
#endif
-int daemon(int nochdir, int noclose)
+int os_daemon(int nochdir, int noclose)
/* compatible with the daemon(3) found on Linuxes and BSDs */
{
int fd;
@@ -91,6 +91,26 @@ int daemon(int nochdir, int noclose)
return 0;
}
+#else /* HAVE_DAEMON */
+
+#ifdef __linux__
+
+/* daemon() needs _DEFAULT_SOURCE */
+#undef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#include <unistd.h>
+
+#else /* !__linux__ */
+
+#include <stdlib.h>
+
+#endif /* !__linux__ */
+
+int os_daemon(int nochdir, int noclose)
+{
+ return daemon(nochdir, noclose);
+}
+
#endif /* HAVE_DAEMON */
/* End of daemon section */
@@ -175,7 +195,7 @@ size_t strlcat(char *dst, const char *src, size_t siz)
return (dlen + (s - src)); /* count does not include NUL */
}
#endif /* __UNUSED__ */
-#endif /* HAVE_STRLCAT */
+#endif /* !HAVE_STRLCAT */
#ifndef HAVE_STRLCPY
@@ -242,6 +262,6 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
return ((size_t) (s - src - 1)); /* count does not include NUL */
}
#endif /* __UNUSED__ */
-#endif /* HAVE_STRLCPY */
+#endif /* !HAVE_STRLCPY */
/* End of strlcat()/strlcpy() section */