diff mbox series

[ovs-dev,1/2] windows: Add set_deatch function to daemon-windows.c

Message ID 20180821145748.9096-1-aserdean@ovn.org
State Superseded
Headers show
Series [ovs-dev,1/2] windows: Add set_deatch function to daemon-windows.c | expand

Commit Message

Alin-Gabriel Serdean Aug. 21, 2018, 2:57 p.m. UTC
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>
---
 lib/daemon-windows.c | 10 +++++++++-
 lib/daemon.h         |  3 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Ben Pfaff Aug. 21, 2018, 6:19 p.m. UTC | #1
On Tue, Aug 21, 2018 at 05:57:47PM +0300, Alin Gabriel Serdean wrote:
> 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>

Thank you for maintaining the Windows port.  We could not do it without
you.

There is a misspelling in the subject: s/deatch/detach/.

I don't entirely understand the implications of this patch.  Guru, I
believe that you were involved in the design of --service.  Do you have
any comments?

For myself:
Acked-by: Ben Pfaff <blp@ovn.org>

Thanks,

Ben.
Gurucharan Shetty Aug. 21, 2018, 7:05 p.m. UTC | #2
On Tue, 21 Aug 2018 at 11:19, Ben Pfaff <blp@ovn.org> wrote:

> On Tue, Aug 21, 2018 at 05:57:47PM +0300, Alin Gabriel Serdean wrote:
> > 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>
>
> Thank you for maintaining the Windows port.  We could not do it without
> you.
>
> There is a misspelling in the subject: s/deatch/detach/.
>
> I don't entirely understand the implications of this patch.  Guru, I
> believe that you were involved in the design of --service.  Do you have
> any comments?
>
I do not see a need for this. But I don't see a harm either. I suppose Alin
forsees a need for this in the future. I am ok with a merge.


>
> For myself:
> Acked-by: Ben Pfaff <blp@ovn.org>
>
> Thanks,
>
> Ben.
>
Alin-Gabriel Serdean Aug. 22, 2018, 1:24 p.m. UTC | #3
> On Tue, 21 Aug 2018 at 11:19, Ben Pfaff <blp@ovn.org> wrote:
> 
> > On Tue, Aug 21, 2018 at 05:57:47PM +0300, Alin Gabriel Serdean wrote:
> > > 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>
> >
> > Thank you for maintaining the Windows port.  We could not do it
> > without you.
> >
> > There is a misspelling in the subject: s/deatch/detach/.
Sorry for the typo 😊. I'll send a V2 
> >
> > I don't entirely understand the implications of this patch.  Guru, I
> > believe that you were involved in the design of --service.  Do you
> > have any comments?
> >
> I do not see a need for this. But I don't see a harm either. I suppose Alin
> forsees a need for this in the future. I am ok with a merge.
> 
I think this will be make the code a bit simpler for both type of developers.
If someone uses get_detach (either for  `--service` or `--detach`) they know
about the users intention.
i.e.:
https://github.com/openvswitch/ovs/blob/master/ovn/utilities/ovn-nbctl.c#L183
> >
> > For myself:
> > Acked-by: Ben Pfaff <blp@ovn.org>
> >
> > Thanks,
> >
> > Ben.
> >
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Gurucharan Shetty Aug. 22, 2018, 6:08 p.m. UTC | #4
On Wed, 22 Aug 2018 at 06:24, <aserdean@ovn.org> wrote:

> > On Tue, 21 Aug 2018 at 11:19, Ben Pfaff <blp@ovn.org> wrote:
> >
> > > On Tue, Aug 21, 2018 at 05:57:47PM +0300, Alin Gabriel Serdean wrote:
> > > > 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>
> > >
> > > Thank you for maintaining the Windows port.  We could not do it
> > > without you.
> > >
> > > There is a misspelling in the subject: s/deatch/detach/.
> Sorry for the typo 😊. I'll send a V2
> > >
> > > I don't entirely understand the implications of this patch.  Guru, I
> > > believe that you were involved in the design of --service.  Do you
> > > have any comments?
> > >
> > I do not see a need for this. But I don't see a harm either. I suppose
> Alin
> > forsees a need for this in the future. I am ok with a merge.
> >
> I think this will be make the code a bit simpler for both type of
> developers.
> If someone uses get_detach (either for  `--service` or `--detach`) they
> know
> about the users intention.
> i.e.:
>
> https://github.com/openvswitch/ovs/blob/master/ovn/utilities/ovn-nbctl.c#L183


makes sense.


>
> > >
> > > For myself:
> > > Acked-by: Ben Pfaff <blp@ovn.org>
> > >
> > > Thanks,
> > >
> > > Ben.
> > >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
diff mbox series

Patch

diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c
index 70c5f5d56..7e5f264f5 100644
--- a/lib/daemon-windows.c
+++ b/lib/daemon-windows.c
@@ -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
@@ -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. */
diff --git a/lib/daemon.h b/lib/daemon.h
index f33e9df8d..094157496 100644
--- a/lib/daemon.h
+++ b/lib/daemon.h
@@ -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:           \
@@ -139,6 +140,7 @@  pid_t read_pidfile(const char *name);
             break;                              \
                                                 \
         case OPT_SERVICE:                       \
+            set_detach();                       \
             break;                              \
                                                 \
         case OPT_SERVICE_MONITOR:               \
@@ -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);