Update src/lcpex/helpers.h

master
Christopher M. Punches 2024-02-08 10:45:26 +00:00
parent 0f35e752d3
commit bb324087a8
1 changed files with 13 additions and 1 deletions

View File

@ -16,6 +16,18 @@ enum CHILD_PIPE_NAMES {
#define BUFFER_SIZE 1024
ssize_t write_all(int fd, const void *buf, size_t count);
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;
}
#endif //LCPEX_HELPERS_H