[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
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 ;-)
On Wed, Nov 25, 2009 at 06:47:42PM +0100, Jim Meyering wrote:
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 ;-)
Thanks - I'm going to push something along these lines. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (2)
-
Jim Meyering -
Richard W.M. Jones