io: write_nointr should treat count -1 as "just do strlen on the buffer"
authorJann Horn <jann@thejh.net>
Tue, 5 Nov 2013 19:13:11 +0000 (20:13 +0100)
committerJann Horn <jann@thejh.net>
Tue, 5 Nov 2013 19:13:11 +0000 (20:13 +0100)
io.c

diff --git a/io.c b/io.c
index dd0d531..17ea4d6 100644 (file)
--- a/io.c
+++ b/io.c
@@ -42,7 +42,8 @@ PUBLIC_FN ssize_t read_nointr(int fd, void *buf, size_t count, int *last_res) {
 //  - -1: error
 //  - 0: stream ended
 //  - 1: no problems occured
-PUBLIC_FN ssize_t write_nointr(int fd, void *buf, size_t count, int *last_res) {
+PUBLIC_FN ssize_t write_nointr(int fd, void *buf, ssize_t count, int *last_res) {
+  if (count == -1) count = strlen(buf);
   errno = 0;
   size_t done = 0;
   while (done < count) {