summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-04-10 18:46:12 +0000
committerRoy Marples <roy@marples.name>2016-04-10 18:46:12 +0000
commitac440ab1f6e869e736742b23671d65ff4cfee296 (patch)
treeac69ed3d96cfaad9ca9576f43969204187c2af38 /dhcpcd.c
parent9e5d26d40ba487807f4df93fafa22dadafe20173 (diff)
downloaddhcpcd-ac440ab1f6e869e736742b23671d65ff4cfee296.tar.xz
Make fork process clearer.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 31dc60c8..ad4b1b5d 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -345,24 +345,19 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
dup2(fd, STDERR_FILENO);
close(fd);
}
- break;
+ ctx->options |= DHCPCD_DAEMONISED;
+ return 0;
default:
/* Wait for child to detach */
close(sidpipe[1]);
if (read(sidpipe[0], &buf, 1) == -1)
logger(ctx, LOG_ERR, "failed to read child: %m");
close(sidpipe[0]);
- break;
- }
- /* Done with the fd now */
- if (pid != 0) {
logger(ctx, LOG_INFO, "forked to background, child pid %d", pid);
ctx->options |= DHCPCD_FORKED;
eloop_exit(ctx->eloop, EXIT_SUCCESS);
return pid;
}
- ctx->options |= DHCPCD_DAEMONISED;
- return pid;
#endif
}
@@ -1800,7 +1795,7 @@ printpidfile:
if (pid == -1)
logger(&ctx, LOG_ERR, "%s: pidfile_lock: %m",
__func__);
- else
+ else
logger(&ctx, LOG_ERR, ""PACKAGE
" already running on pid %d (%s)",
pid, ctx.pidfile);