Commit 10b3eecc authored by Leigh B Stoller's avatar Leigh B Stoller

Changes to ExecQuiet to make sure STDERR is really redirected

in the pipe. When invoked from the web interface STDERR has
been redirected to the apache log file, and if we do not reset
it, error output land there instead of in the pipe we just opened.
parent ddd79c62
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -524,11 +524,28 @@ sub ExecQuiet($)
my ($command) = @_;
my $output = "";
open(PIPE,"$command 2>&1 |") or return -1;
while (<PIPE>) {
$output .= $_;
#
# This open implicitly forks a child, which goes on to execute the
# command. The parent is going to sit in this loop and capture the
# output of the child. We do this so that we have better control
# over the descriptors.
#
my $pid = open(PIPE, "-|");
if (!defined($pid)) {
print STDERR "ExecQuiet Failure; popen failed!\n";
return -1;
}
if ($pid) {
while (<PIPE>) {
$output .= $_;
}
close(PIPE);
}
else {
open(STDERR, ">&STDOUT");
exec($command);
}
close(PIPE);
return $output;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment