From 962cf32ba7b956733cc1ddb6d9ab707cfc577c02 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Sep 2020 20:04:47 +0200 Subject: [PATCH] test/run_input: pass FileDescriptor to dump_input_stream() --- test/run_input.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/run_input.cxx b/test/run_input.cxx index 4c067fb45..63e5f2ab7 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -130,7 +130,7 @@ tag_save(FILE *file, const Tag &tag) } static int -dump_input_stream(InputStream &is) +dump_input_stream(InputStream &is, FileDescriptor out) { const std::lock_guard protect(is.mutex); @@ -155,9 +155,7 @@ dump_input_stream(InputStream &is) if (num_read == 0) break; - ssize_t num_written = write(1, buffer, num_read); - if (num_written <= 0) - break; + out.FullWrite(buffer, num_read); } is.Check(); @@ -234,7 +232,7 @@ try { Mutex mutex; auto is = InputStream::OpenReady(c.uri, mutex); - return dump_input_stream(*is); + return dump_input_stream(*is, FileDescriptor(STDOUT_FILENO)); } catch (...) { PrintException(std::current_exception()); return EXIT_FAILURE;