]> granicus.if.org Git - clang/commitdiff
Echo stderr/stdout from clang subprocess to both the stderr of ccc-analyzer and
authorTed Kremenek <kremenek@apple.com>
Thu, 11 Sep 2008 23:05:26 +0000 (23:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 11 Sep 2008 23:05:26 +0000 (23:05 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56130 91177308-0d34-0410-b5e6-96231b3b80d8

utils/ccc-analyzer

index 823c914203b941796fd9d9d45ee87e3ca8c01c60..739e24805e08d1f7e9f28169ad52aaac09c88397 100755 (executable)
@@ -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?