From a523bb2e04cce01dfc8574217bd45bb716a66e98 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 20 Oct 2018 12:19:31 +0100 Subject: [PATCH] Re-name and fix documentation for ss_read(). The function actually reads until the complete requested amount is read (or it hits end-of-file or another error). --- src/includes/dinit-util.h | 6 +++--- src/proc-service.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/includes/dinit-util.h b/src/includes/dinit-util.h index caedbdd..da57709 100644 --- a/src/includes/dinit-util.h +++ b/src/includes/dinit-util.h @@ -7,9 +7,9 @@ #include #include -// Signal-safe read. Read and re-try if interrupted by signal (EINTR). -// *May* affect errno even on a successful read (when the return is less than n). -inline ssize_t ss_read(int fd, void * buf, size_t n) +// Complete read - read the specified size until end-of-file or error; continue read if +// interrupted by signal. +inline ssize_t complete_read(int fd, void * buf, size_t n) { char * cbuf = static_cast(buf); ssize_t r = 0; diff --git a/src/proc-service.cc b/src/proc-service.cc index d664142..e6ad098 100644 --- a/src/proc-service.cc +++ b/src/proc-service.cc @@ -407,7 +407,7 @@ bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept } char pidbuf[21]; // just enough to hold any 64-bit integer - int r = ss_read(fd, pidbuf, 20); + int r = complete_read(fd, pidbuf, 20); if (r < 0) { // Could not read from PID file log(loglevel_t::ERROR, get_name(), ": could not read from pidfile; ", strerror(errno)); -- 2.25.1