From 7a816d59204025223e074a523fd90c41184b5b83 Mon Sep 17 00:00:00 2001 From: "Christopher M. Punches" Date: Thu, 8 Feb 2024 10:43:01 +0000 Subject: [PATCH] Update src/misc/helpers.cpp --- src/misc/helpers.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/misc/helpers.cpp b/src/misc/helpers.cpp index f34cc9c..0e4e64d 100644 --- a/src/misc/helpers.cpp +++ b/src/misc/helpers.cpp @@ -136,4 +136,19 @@ std::string get_absolute_path(const std::string &relative_path) } return std::string(resolved_path); +} + + +ssize_t write_all(int fd, const void *buf, size_t count) { + const char *p = (const char *)buf; + while (count > 0) { + ssize_t written = write(fd, p, count); + if (written == -1) { + if (errno == EINTR || errno == EAGAIN) continue; // Retry + return -1; // Other errors + } + count -= written; + p += written; + } + return 0; } \ No newline at end of file