[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.

llvm-svn: 241250
This commit is contained in:
Charlie Turner 2015-07-02 09:32:07 +00:00
parent 5b41ea0d56
commit 0912de3216
2 changed files with 2 additions and 2 deletions

View 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

View 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());