assert(s);
target = translate_runlevel(runlevel, &isolate);
- if(!target) {
+ if (!target) {
log_warning("Got request for unknown runlevel %c, ignoring.", runlevel);
return;
}
if (errno == EAGAIN)
return 0;
- log_warning("Failed to read from fifo: %s", strerror(errno));
+ log_warning("Failed to read from fifo: %m");
return -1;
}
if (f->server)
epoll_ctl(f->server->epoll_fd, EPOLL_CTL_DEL, f->fd, NULL);
- close_nointr_nofail(f->fd);
+ safe_close(f->fd);
}
free(f);
while (s->fifos)
fifo_free(s->fifos);
- if (s->epoll_fd >= 0)
- close_nointr_nofail(s->epoll_fd);
+ safe_close(s->epoll_fd);
if (s->bus) {
sd_bus_flush(s->bus);
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
r = -errno;
- log_error("Failed to create epoll object: %s", strerror(errno));
+ log_error("Failed to create epoll object: %m");
goto fail;
}
f = new0(Fifo, 1);
if (!f) {
r = -ENOMEM;
- log_error("Failed to create fifo object: %s",
- strerror(errno));
+ log_error("Failed to create fifo object: %m");
goto fail;
}
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
r = -errno;
fifo_free(f);
- log_error("Failed to add fifo fd to epoll object: %s",
- strerror(errno));
+ log_error("Failed to add fifo fd to epoll object: %m");
goto fail;
}
s->n_fifos ++;
}
- r = bus_connect_system(&s->bus);
+ r = bus_open_system_systemd(&s->bus);
if (r < 0) {
log_error("Failed to get D-Bus connection: %s", strerror(-r));
r = -EIO;
umask(0022);
- if ((n = sd_listen_fds(true)) < 0) {
+ n = sd_listen_fds(true);
+ if (n < 0) {
log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
return EXIT_FAILURE;
}
if (server_init(&server, (unsigned) n) < 0)
return EXIT_FAILURE;
- log_debug("systemd-initctl running as pid %lu", (unsigned long) getpid());
+ log_debug("systemd-initctl running as pid "PID_FMT, getpid());
sd_notify(false,
"READY=1\n"
if (errno == EINTR)
continue;
- log_error("epoll_wait() failed: %s", strerror(errno));
+ log_error("epoll_wait() failed: %m");
goto fail;
}
r = EXIT_SUCCESS;
- log_debug("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
+ log_debug("systemd-initctl stopped as pid "PID_FMT, getpid());
fail:
sd_notify(false,