forked from OSchip/llvm-project
Echo stderr/stdout from clang subprocess to both the stderr of ccc-analyzer and
to an output file. This way users can both see the output of 'clang' as well as enable background logging of files that clang encounters problems on. llvm-svn: 56130
This commit is contained in:
parent
7d01c0654c
commit
4ab81cbe2f
|
@ -117,15 +117,24 @@ sub Analyze {
|
|||
# Capture the STDOUT of clang and reroute it to ccc-analyzer's STDERR.
|
||||
# We save the output file in the 'crashes' directory if clang encounters
|
||||
# any problems with the file.
|
||||
my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
|
||||
pipe (FROM_CHILD, TO_PARENT);
|
||||
my $pid = fork();
|
||||
if ($pid == 0) {
|
||||
open(STDOUT,">&", \*STDERR);
|
||||
open(STDERR,">&", $ofh);
|
||||
close FROM_CHILD;
|
||||
open(STDOUT,">&", \*TO_PARENT);
|
||||
open(STDERR,">&", \*TO_PARENT);
|
||||
exec $Cmd, @CmdArgs;
|
||||
}
|
||||
close ($ofh);
|
||||
wait;
|
||||
|
||||
close TO_PARENT;
|
||||
my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
|
||||
|
||||
while (<FROM_CHILD>) {
|
||||
print $ofh $_;
|
||||
print STDERR $_;
|
||||
}
|
||||
|
||||
waitpid($pid,0);
|
||||
my $Result = $?;
|
||||
|
||||
# Did the command die because of a signal?
|
||||
|
|
Loading…
Reference in New Issue