]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
control: avoid unlinking the socket when sending commands
authorRoy Marples <roy@marples.name>
Thu, 9 Jan 2020 15:59:15 +0000 (15:59 +0000)
committerRoy Marples <roy@marples.name>
Thu, 9 Jan 2020 15:59:15 +0000 (15:59 +0000)
src/control.c
src/dhcpcd.c

index c81d2cb340ac5973072cc092b4c74628f4cf402b..eb43a93504d3a47492ba510b02db94fed71dfe63 100644 (file)
@@ -269,6 +269,9 @@ control_stop(struct dhcpcd_ctx *ctx)
        int retval = 0;
        struct fd_list *l;
 
+       if (ctx->options & DHCPCD_FORKED)
+               return 0;
+
        if (ctx->control_fd != -1) {
                eloop_event_delete(ctx->eloop, ctx->control_fd);
                close(ctx->control_fd);
index 13376b92b7a58c65f92072c7fa3fb7843d0e82fa..85af5494cab17981d0a8eb429af41e89f98e72d2 100644 (file)
@@ -1910,6 +1910,7 @@ printpidfile:
            !(ctx.options & DHCPCD_TEST))
        {
 #endif
+               ctx.options |= DHCPCD_FORKED; /* avoid socket unlink */
                if (!(ctx.options & DHCPCD_MASTER))
                        ctx.control_fd = control_open(argv[optind]);
                if (ctx.control_fd == -1)
@@ -1928,6 +1929,7 @@ printpidfile:
                        if (errno != ENOENT)
                                logerr("%s: control_open", __func__);
                }
+               ctx.options &= ~DHCPCD_FORKED;
 #ifdef USE_SIGNALS
        }
 #endif