[GraphWriter] Don't wait on xdg-open when not on Apple.
authorCharlie Turner <charlie.turner@arm.com>
Thu, 2 Jul 2015 09:32:07 +0000 (09:32 +0000)
committerCharlie Turner <charlie.turner@arm.com>
Thu, 2 Jul 2015 09:32:07 +0000 (09:32 +0000)
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.

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

include/llvm/Support/GraphWriter.h
lib/Support/GraphWriter.cpp

index 7d1c273c988d1c039f84066932bf6f477b36c370..b1af3d7c2632bec3c79538d46334ed13cbf86c48 100644 (file)
@@ -353,7 +353,7 @@ void ViewGraph(const GraphType &G, const Twine &Name,
   if (Filename.empty())
     return;
 
-  DisplayGraph(Filename, true, Program);
+  DisplayGraph(Filename, false, Program);
 }
 
 } // End llvm namespace
index 97aedc88473a2db08d6fa7ff3ef82d36041c5007..a9b022041468bc3f81f0c44ff1fb6662f5beca44 100644 (file)
@@ -135,12 +135,12 @@ static const char *getProgramName(GraphProgram::Name program) {
 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());