comparison src/dhcpcd.c @ 5538:fc24946f9b2a draft

dhcpcd: Don't create launcher process if keeping in foreground There is little point.
author Roy Marples <roy@marples.name>
date Wed, 11 Nov 2020 17:44:55 +0000
parents 4492d1d88fdd
children c9182c3618e6
comparison
equal deleted inserted replaced
5537:4492d1d88fdd 5538:fc24946f9b2a
2242 2242
2243 loginfox(PACKAGE "-" VERSION " starting"); 2243 loginfox(PACKAGE "-" VERSION " starting");
2244 if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL) 2244 if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL)
2245 logwarn("freopen stdin"); 2245 logwarn("freopen stdin");
2246 2246
2247 if (!(ctx.options & DHCPCD_DAEMONISE))
2248 goto start_master;
2249
2247 #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK) 2250 #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
2248 if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 || 2251 if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 ||
2249 (ctx.stderr_valid && 2252 (ctx.stderr_valid &&
2250 xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, stderr_fd) == -1)) 2253 xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, stderr_fd) == -1))
2251 { 2254 {
2333 goto run_loop; 2336 goto run_loop;
2334 } 2337 }
2335 2338
2336 /* We have now forked, setsid, forked once more. 2339 /* We have now forked, setsid, forked once more.
2337 * From this point on, we are the controlling daemon. */ 2340 * From this point on, we are the controlling daemon. */
2341 logdebugx("spawned master process on PID %d", getpid());
2342 start_master:
2338 ctx.options |= DHCPCD_STARTED; 2343 ctx.options |= DHCPCD_STARTED;
2339 logdebugx("spawned master process on PID %d", getpid());
2340 if ((pid = pidfile_lock(ctx.pidfile)) != 0) { 2344 if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
2341 logerr("%s: pidfile_lock %d", __func__, pid); 2345 logerr("%s: pidfile_lock %d", __func__, pid);
2342 #ifdef PRIVSEP 2346 #ifdef PRIVSEP
2343 /* privsep has not started ... */ 2347 /* privsep has not started ... */
2344 ctx.options &= ~DHCPCD_PRIVSEP; 2348 ctx.options &= ~DHCPCD_PRIVSEP;