# HG changeset patch # User Roy Marples # Date 1605116695 0 # Node ID fc24946f9b2ac278141faf3ef5b36469a7a3d092 # Parent 4492d1d88fdde567636b8954b77893cefbb9a5ce dhcpcd: Don't create launcher process if keeping in foreground There is little point. diff -r 4492d1d88fdd -r fc24946f9b2a src/dhcpcd.c --- a/src/dhcpcd.c Wed Nov 11 17:41:16 2020 +0000 +++ b/src/dhcpcd.c Wed Nov 11 17:44:55 2020 +0000 @@ -2244,6 +2244,9 @@ if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL) logwarn("freopen stdin"); + if (!(ctx.options & DHCPCD_DAEMONISE)) + goto start_master; + #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK) if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 || (ctx.stderr_valid && @@ -2335,8 +2338,9 @@ /* We have now forked, setsid, forked once more. * From this point on, we are the controlling daemon. */ + logdebugx("spawned master process on PID %d", getpid()); +start_master: ctx.options |= DHCPCD_STARTED; - logdebugx("spawned master process on PID %d", getpid()); if ((pid = pidfile_lock(ctx.pidfile)) != 0) { logerr("%s: pidfile_lock %d", __func__, pid); #ifdef PRIVSEP diff -r 4492d1d88fdd -r fc24946f9b2a src/privsep.c --- a/src/privsep.c Wed Nov 11 17:41:16 2020 +0000 +++ b/src/privsep.c Wed Nov 11 17:44:55 2020 +0000 @@ -163,12 +163,13 @@ #endif } +#define DHC_NOCHKIO (DHCPCD_STARTED | DHCPCD_DAEMONISE) /* Prohibit writing to files. * Obviously this won't work if we are using a logfile * or redirecting stderr to a file. */ - if (ctx->logfile == NULL && - (ctx->options & DHCPCD_STARTED || - !ctx->stderr_valid || isatty(STDERR_FILENO) == 1)) + if ((ctx->options & DHC_NOCHKIO) == DHC_NOCHKIO || + (ctx->logfile == NULL && + (!ctx->stderr_valid || isatty(STDERR_FILENO) == 1))) { if (setrlimit(RLIMIT_FSIZE, &rzero) == -1) logerr("setrlimit RLIMIT_FSIZE");