X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdaemon-windows.c;h=f94ad9bd0fdca835171999b8cceb3c825b966100;hb=28c5588e8e1a8d091c5d2275232c35f2968a97fa;hp=0893755ae722d8153a3eb3fbf0cc541d62e07dfd;hpb=a9e9db79e7e6cdcb195e91c431c4a335b72b14da;p=sliver-openvswitch.git diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c index 0893755ae..f94ad9bd0 100644 --- a/lib/daemon-windows.c +++ b/lib/daemon-windows.c @@ -16,12 +16,13 @@ #include #include "daemon.h" +#include "daemon-private.h" #include #include #include "poll-loop.h" #include "vlog.h" -VLOG_DEFINE_THIS_MODULE(daemon); +VLOG_DEFINE_THIS_MODULE(daemon_windows); static bool service_create; /* Was --service specified? */ static bool service_started; /* Have we dispatched service to start? */ @@ -30,12 +31,12 @@ static bool service_started; /* Have we dispatched service to start? */ * unexpectedly? */ static bool monitor; -static bool detach; /* Was --detach specified? */ -static bool detached; /* Running as the child process. */ -static HANDLE write_handle; /* End of pipe to write to parent. */ +bool detach; /* Was --detach specified? */ +static bool detached; /* Running as the child process. */ +static HANDLE write_handle; /* End of pipe to write to parent. */ -static char *pidfile; /* --pidfile: Name of pidfile (null if none). */ -static FILE *filep_pidfile; /* File pointer to access the pidfile. */ +char *pidfile; /* --pidfile: Name of pidfile (null if none). */ +static FILE *filep_pidfile; /* File pointer to access the pidfile. */ /* Handle to the Services Manager and the created service. */ static SC_HANDLE manager, service; @@ -395,25 +396,6 @@ detach_process(int argc, char *argv[]) exit(0); } -/* Will daemonize() really detach? */ -bool -get_detach() -{ - return detach; -} - -void -daemon_save_fd(int fd OVS_UNUSED) -{ -} - -void -daemonize(void) -{ - daemonize_start(); - daemonize_complete(); -} - static void unlink_pidfile(void) { @@ -472,6 +454,9 @@ daemonize_complete(void) * communicate with the parent to inform that the child is ready. */ if (detached) { int error; + + close_standard_fds(); + error = WriteFile(write_handle, "a", 1, NULL, NULL); if (!error) { VLOG_FATAL("Failed to communicate with the parent (%s)", @@ -484,7 +469,7 @@ daemonize_complete(void) /* Returns the file name that would be used for a pidfile if 'name' were * provided to set_pidfile(). The caller must free the returned string. */ -static char * +char * make_pidfile_name(const char *name) { if (name && strchr(name, ':')) { @@ -493,17 +478,3 @@ make_pidfile_name(const char *name) return xasprintf("%s/%s.pid", ovs_rundir(), program_name); } } - -/* Sets up a following call to daemonize() to create a pidfile named 'name'. - * If 'name' begins with '/', then it is treated as an absolute path. - * Otherwise, it is taken relative to RUNDIR, which is $(prefix)/var/run by - * default. - * - * If 'name' is null, then program_name followed by ".pid" is used. */ -void -set_pidfile(const char *name) -{ - assert_single_threaded(); - free(pidfile); - pidfile = make_pidfile_name(name); -}