summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-13 17:51:16 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-13 17:51:16 -0400
commit405ba31245d0916895e707b8c10cc71cf40045a0 (patch)
treef0e7be42021c2784d9b3bc7434984722cb49aacd
parent0f1621dc0ebb0e97cfeb9c7c5585ee8b545228ba (diff)
test runner: for notify events, fold the nl into the same write if possible
-rw-r--r--test/runner.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/runner.c b/test/runner.c
index a1d7181..e1aed70 100644
--- a/test/runner.c
+++ b/test/runner.c
@@ -126,10 +126,12 @@ int main(int argc, char *argv[]) {
while (1) {
union addr client_addr;
socklen_t client_size;
- char buf[4096];
- ssize_t bytes_read = recvfrom(notify_sock, buf, sizeof(buf), 0, &client_addr.gen, &client_size);
+ char buf[4097];
+ ssize_t bytes_read = recvfrom(notify_sock, buf, sizeof(buf)-1, 0, &client_addr.gen, &client_size);
if (bytes_read < 1)
error(EXIT_FAILURE, errno, "recvfrom");
+ buf[bytes_read] = '\n';
+ bytes_read++;
ssize_t bytes_written = 0;
while (bytes_written < bytes_read) {
ssize_t n = write(2, &(buf[bytes_written]), bytes_read-bytes_written);
@@ -141,7 +143,6 @@ int main(int argc, char *argv[]) {
}
if (bytes_written < 0)
error(EXIT_FAILURE, errno, "write");
- write(2, "\n", 1);
}
error(EXIT_FAILURE, 0, "not reached");
return EXIT_FAILURE;