[ovs-dev] [PATCH v3 2/2] windows: Add set_detach function to daemon-windows.c

Anand Kumar kumaranand at vmware.com
Thu Oct 18 16:12:46 UTC 2018


Acked-by: Anand Kumar <kumaranand at vmware.com>

Thanks,
Anand Kumar

On 10/5/18, 7:55 AM, "ovs-dev-bounces at openvswitch.org on behalf of Alin Gabriel Serdean" <ovs-dev-bounces at openvswitch.org on behalf of aserdean at ovn.org> 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 at ovn.org>
    Acked-by: Ben Pfaff <blp at ovn.org>
    ---
    v3: no change.
    v2: Fix typo in title, add Ack
    ---
     lib/daemon-windows.c | 10 +++++++++-
     lib/daemon.h         |  3 +++
     2 files changed, 12 insertions(+), 1 deletion(-)
    
    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);
    -- 
    2.16.1.windows.1
    
    _______________________________________________
    dev mailing list
    dev at openvswitch.org
    https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&amp;data=02%7C01%7Ckumaranand%40vmware.com%7C8a0d9c61c3f34216ab8408d62ad29470%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636743481259851516&amp;sdata=I3H2lLIx4%2FpkmibFxXcB3Z5BkCCY9vNW3I9%2BZpMHt1s%3D&amp;reserved=0
    




More information about the dev mailing list