diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-11-06 17:27:02 +0000 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-11-09 11:05:19 +0000 |
commit | a25d175cf6e8283288fd6d209b37b09ffee0dcf3 (patch) | |
tree | ec3b67a6859e08802ce47f8067cd1a089106d707 /daemon/guestfsd.c | |
parent | d714547ab361962ca6f76ec07736f1515595b2df (diff) | |
download | libguestfs-a25d175cf6e8283288fd6d209b37b09ffee0dcf3.tar.gz libguestfs-a25d175cf6e8283288fd6d209b37b09ffee0dcf3.tar.xz libguestfs-a25d175cf6e8283288fd6d209b37b09ffee0dcf3.zip |
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.
Diffstat (limited to 'daemon/guestfsd.c')
-rw-r--r-- | daemon/guestfsd.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index bf06c73d..370eea8d 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -38,6 +38,8 @@ #include <printf.h> #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); + } } } } |