Richard W.M. Jones
2009-Nov-25 15:03 UTC
[Libguestfs] [PATCH] daemon/Win32: Windows can't daemonize.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -------------- next part -------------->From bf61343531ab607551676c548d18fee46f702a15 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Wed, 25 Nov 2009 14:59:30 +0000 Subject: [PATCH 6/7] daemon/Win32: Windows can't daemonize. --- daemon/guestfsd.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 40b3c2f..d3b754d 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -335,10 +335,15 @@ main (int argc, char *argv[]) /* Fork into the background. */ if (!dont_fork) { +#ifndef WIN32 if (daemon (0, 1) == -1) { perror ("daemon"); exit (EXIT_FAILURE); } +#else /* WIN32 */ + fprintf (stderr, "On Windows the daemon does not support forking into the background.\nYou *must* run the daemon with the -f option.\n"); + exit (EXIT_FAILURE); +#endif /* WIN32 */ } /* Enter the main loop, reading and performing actions. */ -- 1.6.5.2
Jim Meyering
2009-Nov-25 17:47 UTC
[Libguestfs] [PATCH] daemon/Win32: Windows can't daemonize.
Richard W.M. Jones wrote:> Subject: [PATCH 6/7] daemon/Win32: Windows can't daemonize. > > --- > daemon/guestfsd.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c > index 40b3c2f..d3b754d 100644 > --- a/daemon/guestfsd.c > +++ b/daemon/guestfsd.c > @@ -335,10 +335,15 @@ main (int argc, char *argv[]) > > /* Fork into the background. */ > if (!dont_fork) { > +#ifndef WIN32 > if (daemon (0, 1) == -1) { > perror ("daemon"); > exit (EXIT_FAILURE); > } > +#else /* WIN32 */ > + fprintf (stderr, "On Windows the daemon does not support forking into the background.\nYou *must* run the daemon with the -f option.\n"); > + exit (EXIT_FAILURE); > +#endif /* WIN32 */How about defining a daemon function above, #ifdef WIN32 static inline int daemon (...) { fprintf (stderr, "On Windows the daemon does not support forking into " "the background.\nYou *must* run the daemon with the -f option.\n"); exit (EXIT_FAILURE); } #endif /* WIN32 */ Then you don't need any of those ugly in-function #ifdefs. Bonus: no lines longer than 80 columns ;-)
Seemingly Similar Threads
- [PATCH] daemon/Win32: Use xdr_u_int for PortableXDR compatibility.
- [PATCH] daemon/Win32: Windows replacement for umask.
- [PATCH] daemon: improve internal commandrvf
- [PATCH 1/2] daemon: NFC Use symbolic names in commandrvf
- [PATCH 0/7] Better testing of the guestfsd daemon.