aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 35d7ee6..b87e9b5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -140,6 +140,22 @@ readall(int fd, void *buf, size_t n)
return r;
}
+int
+pwriteall(int fd, void *buf, size_t n, size_t ptr)
+{
+ char *buffer = buf;
+ ssize_t r;
+ while (n) {
+ r = pwrite(fd, buffer, n, ptr);
+ if (r < 0)
+ return -1;
+ buffer += (size_t)r;
+ n -= (size_t)r;
+ ptr += (size_t)r;
+ }
+ return 0;
+}
+
static inline pid_t
enfork(int status)