From 946c815024203bf790e401b516a584f18ca2d1a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 21 Sep 2020 18:32:29 +0100 Subject: [PATCH] tests: don't mix FILE* and UNIX FD I/O on same stream MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is currently a hang in test27 that exhibits itself on FreeBSD 11.4 only. The behaviour is that virCommandProcessIO gets POLLIN on the FD for stdout, but read() blocks. Meanwhile commandtest also blocks in write for stderr because the pipe buffers are full. This fix in commandhelper likely does not really address the root cause just hides it due to the buffering done by FILE *. Mixing UNIX FD I/O and FILE * I/O is bad practice regardless. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrangé --- tests/commandhelper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 05f577730f..7c260c4e13 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -221,9 +221,9 @@ int main(int argc, char **argv) { } for (i = 0; i < numpollfds; i++) { - if (write(STDOUT_FILENO, buffers[i], buflen[i]) != buflen[i]) + if (fwrite(buffers[i], 1, buflen[i], stdout) != buflen[i]) goto cleanup; - if (write(STDERR_FILENO, buffers[i], buflen[i]) != buflen[i]) + if (fwrite(buffers[i], 1, buflen[i], stderr) != buflen[i]) goto cleanup; } -- 2.47.2