From 405ba31245d0916895e707b8c10cc71cf40045a0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 13 Sep 2015 17:51:16 -0400 Subject: test runner: for notify events, fold the nl into the same write if possible --- test/runner.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') 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; -- cgit v1.2.2