diff options
-rw-r--r-- | osdep.h | 1 | ||||
-rw-r--r-- | oslib-posix.c | 16 | ||||
-rw-r--r-- | qemu-nbd.c | 2 |
3 files changed, 18 insertions, 1 deletions
@@ -88,6 +88,7 @@ # define QEMU_GNUC_PREREQ(maj, min) 0 #endif +int qemu_daemon(int nochdir, int noclose); void *qemu_memalign(size_t alignment, size_t size); void *qemu_vmalloc(size_t size); void qemu_vfree(void *ptr); diff --git a/oslib-posix.c b/oslib-posix.c index 7bc5f7cf09..3a18e865f3 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -26,11 +26,27 @@ * THE SOFTWARE. */ +/* The following block of code temporarily renames the daemon() function so the + compiler does not see the warning associated with it in stdlib.h on OSX */ +#ifdef __APPLE__ +#define daemon qemu_fake_daemon_function +#include <stdlib.h> +#undef daemon +extern int daemon(int, int); +#endif + #include "config-host.h" #include "sysemu.h" #include "trace.h" #include "qemu_socket.h" + + +int qemu_daemon(int nochdir, int noclose) +{ + return daemon(nochdir, noclose); +} + void *qemu_oom_check(void *ptr) { if (ptr == NULL) { diff --git a/qemu-nbd.c b/qemu-nbd.c index 110d78e6a4..d91c02ce49 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -359,7 +359,7 @@ int main(int argc, char **argv) if (!verbose) { /* detach client and server */ - if (daemon(0, 0) == -1) { + if (qemu_daemon(0, 0) == -1) { err(EXIT_FAILURE, "Failed to daemonize"); } } |