aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan T. DeKok <aland@freeradius.org>2009-02-08 11:40:34 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-15 13:06:45 (GMT)
commit3ffb0e42535c09ead1856b73cac9623a908d4d28 (patch)
treeca4fb0e0f6959b349f4212e617ac0ce6cb3bace5 /src
parenta57dfbbe5f5ce649e3ead1b6b0a3eadd0b890067 (diff)
downloadhostap-06-3ffb0e42535c09ead1856b73cac9623a908d4d28.zip
hostap-06-3ffb0e42535c09ead1856b73cac9623a908d4d28.tar.gz
hostap-06-3ffb0e42535c09ead1856b73cac9623a908d4d28.tar.bz2
Create os_daemon for OS X, as it's now deprecated (Leopard)
Using it results in an error at build time. So we replace it. (cherry picked from commit 02a89365abba33fb462f739c325dc9cc3e847dae)
Diffstat (limited to 'src')
-rw-r--r--src/utils/os_unix.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 0789b78..060892d 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -76,12 +76,47 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
}
+#ifdef __APPLE__
+#include <fcntl.h>
+static int os_daemon(int nochdir, int noclose)
+{
+ int devnull;
+
+ if (chdir("/") < 0)
+ return -1;
+
+ devnull = open("/dev/null", O_RDWR);
+ if (devnull < 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 /* __APPLE__ */
+#define os_daemon daemon
+#endif /* __APPLE__ */
+
+
int os_daemonize(const char *pid_file)
{
#ifdef __uClinux__
return -1;
#else /* __uClinux__ */
- if (daemon(0, 0)) {
+ if (os_daemon(0, 0)) {
perror("daemon");
return -1;
}