[PATCH] Create os_daemon for OS X, as it's now deprecated.
Alan T. DeKok
aland
Sun Dec 14 01:10:36 PST 2008
Using it results in an error at build time. So we replace it.
---
src/utils/os_unix.c | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index a428195..3fded8d 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -75,13 +75,45 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
return 0;
}
+#ifdef __APPLE__
+#include <fcntl.h>
+static int os_daemon(int nochdir, int noclose)
+{
+ int devnull;
+
+ if (chdir("/") < 0)
+ return -1;
+
+ if ((devnull = open("/dev/null", O_RDWR)) < 0)
+ return -1;
+
+ if (dup2(devnull, STDIN_FILENO) < 0) {
+ close(devnull);
+ return -1;
+ }
+
+ if (dup2(devnull, STDOUT_FILENO) < 0) {
+ close(devnull);
+ return -1;
+ }
+
+ if (dup2(devnull, STDERR_FILENO) < 0) {
+ close(devnull);
+ return -1;
+ }
+
+ return 0;
+}
+#else
+#define os_daemon daemon
+#endif
int os_daemonize(const char *pid_file)
{
#ifdef __unclinux
return -1;
#else /* __uclinux */
- if (daemon(0, 0)) {
+ if (os_daemon(0, 0)) {
perror("daemon");
return -1;
}
--
1.6.0.2
--------------010000090207030001020306--
More information about the Hostap
mailing list