The function actually reads until the complete requested amount is read
(or it hits end-of-file or another error).
#include <sys/types.h>
#include <unistd.h>
-// 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<char *>(buf);
ssize_t r = 0;
}
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));