Skip to content

Commit

Permalink
windows: Add set_detach function to daemon-windows.c
Browse files Browse the repository at this point in the history
The daemon-windows file is missing a `set_detach` routine, so add it.

This will be useful in the long run.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Anand Kumar <kumaranand@vmware.com>
  • Loading branch information
aserdean committed Oct 24, 2018
1 parent 22922fd commit 7a109aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/daemon-windows.c
Expand Up @@ -82,6 +82,14 @@ daemon_usage(void)
"unexpected failure. \n");
}

/* Sets up a following call to service_start() to detach from the foreground
* session, running this process in the background. */
void
set_detach(void)
{
detach = true;
}

/* Registers the call-back and configures the actions in case of a failure
* with the Windows services manager. */
void
Expand Down Expand Up @@ -357,7 +365,7 @@ detach_process(int argc, char *argv[])

/* We are only interested in the '--detach' and '--pipe-handle'. */
for (i = 0; i < argc; i ++) {
if (!strcmp(argv[i], "--detach")) {
if (!detach && !strcmp(argv[i], "--detach")) {
detach = true;
} else if (!strncmp(argv[i], "--pipe-handle", 13)) {
/* If running as a child, return. */
Expand Down
3 changes: 3 additions & 0 deletions lib/daemon.h
Expand Up @@ -121,6 +121,7 @@ pid_t read_pidfile(const char *name);

#define DAEMON_OPTION_HANDLERS \
case OPT_DETACH: \
set_detach(); \
break; \
\
case OPT_NO_SELF_CONFINEMENT: \
Expand All @@ -139,6 +140,7 @@ pid_t read_pidfile(const char *name);
break; \
\
case OPT_SERVICE: \
set_detach(); \
break; \
\
case OPT_SERVICE_MONITOR: \
Expand All @@ -159,6 +161,7 @@ pid_t read_pidfile(const char *name);

void control_handler(DWORD request);
void set_pipe_handle(const char *pipe_handle);
void set_detach(void);
#endif /* _WIN32 */

bool get_detach(void);
Expand Down

0 comments on commit 7a109aa

Please sign in to comment.