fixed nonsense with truncation

This commit is contained in:
phanes
2024-02-08 05:57:09 -05:00
parent bb324087a8
commit 344cbfc56e
5 changed files with 20 additions and 30 deletions

15
src/lcpex/helpers.cpp Normal file
View File

@@ -0,0 +1,15 @@
#include "helpers.h"
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;
}