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
}
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);