>From e924f1b87381b3f38b2ba98d4373ede8995ad82b Mon Sep 17 00:00:00 2001 From: Richard W.M. Jones Date: Fri, 6 Nov 2009 17:27:02 +0000 Subject: [PATCH 2/2] daemon: Always reflect command stderr to stderr when debugging. When debugging (ie. LIBGUESTFS_DEBUG=1 & verbose flag set in daemon) always reflect any stderr output from commands that we run to stderr of the daemon, so it is visible. Previously if stderror == NULL in command*, stderr output was just eaten and discarded which meant useful error messages could be lost. --- daemon/guestfsd.c | 25 ++++++++++++++++--------- 1 files changed, 16 insertions(+), 9 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index bf06c73..370eea8 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -38,6 +38,8 @@ #include #include "c-ctype.h" +#include "ignore-value.h" + #include "daemon.h" static char *read_cmdline (void); @@ -742,15 +744,20 @@ commandrvf (char **stdoutput, char **stderror, int flags, } if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; } - if (r > 0 && stderror) { - se_size += r; - p = realloc (*stderror, se_size); - if (p == NULL) { - perror ("realloc"); - goto quit; - } - *stderror = p; - memcpy (*stderror + se_size - r, buf, r); + if (r > 0) { + if (verbose) + ignore_value (write (2, buf, r)); + + if (stderror) { + se_size += r; + p = realloc (*stderror, se_size); + if (p == NULL) { + perror ("realloc"); + goto quit; + } + *stderror = p; + memcpy (*stderror + se_size - r, buf, r); + } } } } -- 1.6.2.5