[llvm] r241250 - [GraphWriter] Don't wait on xdg-open when not on Apple.

Charlie Turner charlie.turner at arm.com
Thu Jul 2 02:32:07 PDT 2015


Author: chatur01
Date: Thu Jul  2 04:32:07 2015
New Revision: 241250

URL: http://llvm.org/viewvc/llvm-project?rev=241250&view=rev
Log:
[GraphWriter] Don't wait on xdg-open when not on Apple.

By default, the GraphWriter code assumes that the generic file open
program (`open` on Apple, `xdg-open` on other systems) can wait on the
forked proces to complete. When the fork ends, the code would delete
the temporary dot files created, and return.

On GNU/Linux, the xdg-open program does not have a "wait for your fork
to complete before dying" option. So the behaviour was that xdg-open
would launch a process, quickly die itself, and then the GraphWriter
code would think its OK to quickly delete all the temporary files.
Once the temporary files were deleted, the dot viewers would get very
upset, and often give you weird errors.

This change only waits on the generic open program on Apple platforms.
Elsewhere, we don't wait on the process, and hence we don't try and
clean up the temporary files.

Modified:
    llvm/trunk/include/llvm/Support/GraphWriter.h
    llvm/trunk/lib/Support/GraphWriter.cpp

Modified: llvm/trunk/include/llvm/Support/GraphWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=241250&r1=241249&r2=241250&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GraphWriter.h (original)
+++ llvm/trunk/include/llvm/Support/GraphWriter.h Thu Jul  2 04:32:07 2015
@@ -353,7 +353,7 @@ void ViewGraph(const GraphType &G, const
   if (Filename.empty())
     return;
 
-  DisplayGraph(Filename, true, Program);
+  DisplayGraph(Filename, false, Program);
 }
 
 } // End llvm namespace

Modified: llvm/trunk/lib/Support/GraphWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=241250&r1=241249&r2=241250&view=diff
==============================================================================
--- llvm/trunk/lib/Support/GraphWriter.cpp (original)
+++ llvm/trunk/lib/Support/GraphWriter.cpp Thu Jul  2 04:32:07 2015
@@ -135,12 +135,12 @@ static const char *getProgramName(GraphP
 bool llvm::DisplayGraph(StringRef FilenameRef, bool wait,
                         GraphProgram::Name program) {
   std::string Filename = FilenameRef;
-  wait &= !ViewBackground;
   std::string ErrMsg;
   std::string ViewerPath;
   GraphSession S;
 
 #ifdef __APPLE__
+  wait &= !ViewBackground;
   if (S.TryFindProgram("open", ViewerPath)) {
     std::vector<const char *> args;
     args.push_back(ViewerPath.c_str());





More information about the llvm-commits mailing list