}
/* Ensure we have the needed directories */
- if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST) {
+ if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
syslog(LOG_ERR, "mkdir `%s': %m", RUNDIR);
- exit(EXIT_FAILURE);
- }
- if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST) {
+ if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
syslog(LOG_ERR, "mkdir `%s': %m", DBDIR);
- exit(EXIT_FAILURE);
- }
pidfd = open(pidfile, O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
- if (pidfd == -1) {
+ if (pidfd == -1)
syslog(LOG_ERR, "open `%s': %m", pidfile);
- exit(EXIT_FAILURE);
- }
- /* Lock the file so that only one instance of dhcpcd runs
- * on an interface */
- if (flock(pidfd, LOCK_EX | LOCK_NB) == -1) {
- syslog(LOG_ERR, "flock `%s': %m", pidfile);
- exit(EXIT_FAILURE);
+ else {
+ /* Lock the file so that only one instance of dhcpcd
+ * runs on an interface */
+ if (flock(pidfd, LOCK_EX | LOCK_NB) == -1) {
+ syslog(LOG_ERR, "flock `%s': %m", pidfile);
+ exit(EXIT_FAILURE);
+ }
+ if (set_cloexec(pidfd) == -1)
+ exit(EXIT_FAILURE);
+ writepid(pidfd, getpid());
}
- if (set_cloexec(pidfd) == -1)
- exit(EXIT_FAILURE);
- writepid(pidfd, getpid());
}
syslog(LOG_INFO, "version " VERSION " starting");
add_event(signal_fd, handle_signal, NULL);
if (options & DHCPCD_MASTER) {
- if (start_control() == -1) {
+ if (start_control() == -1)
syslog(LOG_ERR, "start_control: %m");
- exit(EXIT_FAILURE);
- }
}
if (init_sockets() == -1) {
if (!(options & DHCPCD_BACKGROUND)) {
/* If we don't have a carrier, we may have to wait for a second
- * before one becomes available if we brought an interface up. */
+ * before one becomes available if we brought an interface up */
if (opt == 0 &&
options & DHCPCD_LINK &&
options & DHCPCD_WAITUP &&