3 int read_in_full(int fd
, void *buf
, size_t count
)
9 ssize_t loaded
= xread(fd
, p
, count
);
11 return total
? total
: loaded
;
20 int write_in_full(int fd
, const void *buf
, size_t count
)
26 size_t written
= xwrite(fd
, p
, count
);
41 void write_or_die(int fd
, const void *buf
, size_t count
)
43 if (write_in_full(fd
, buf
, count
) < 0) {
46 die("write error (%s)", strerror(errno
));
50 int write_or_whine_pipe(int fd
, const void *buf
, size_t count
, const char *msg
)
52 if (write_in_full(fd
, buf
, count
) < 0) {
55 fprintf(stderr
, "%s: write error (%s)\n",
56 msg
, strerror(errno
));
63 int write_or_whine(int fd
, const void *buf
, size_t count
, const char *msg
)
65 if (write_in_full(fd
, buf
, count
) < 0) {
66 fprintf(stderr
, "%s: write error (%s)\n",
67 msg
, strerror(errno
));