diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-18 11:19:36 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-18 11:19:36 +0000 |
commit | 2836c4ccb60429bf79b022bc6677598ffa13806b (patch) | |
tree | e2e139de05142f89cbd3db4f0be8d96d9a848c2b /clang | |
parent | 817e7e4fb834e8efcbb02c5784d1edde24a12d24 (diff) | |
download | bcm5719-llvm-2836c4ccb60429bf79b022bc6677598ffa13806b.tar.gz bcm5719-llvm-2836c4ccb60429bf79b022bc6677598ffa13806b.zip |
CIndex: replace fork/exec with our portable ExecuteAndWait wrapper.
llvm-svn: 84414
Diffstat (limited to 'clang')
-rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index c262f672870..4ade9477c56 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -24,10 +24,10 @@ #include "clang/Frontend/ASTUnit.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/System/Path.h" +#include "llvm/System/Program.h" #include <cstdio> #ifndef _MSC_VER #include <dlfcn.h> -#include <sys/wait.h> #endif #include <vector> @@ -356,22 +356,8 @@ CXTranslationUnit clang_createTranslationUnitFromSourceFile( argv.push_back(NULL); // Generate the AST file in a separate process. - pid_t child_pid = fork(); - if (child_pid == 0) { // Child process - - // Execute the command, passing the appropriate arguments. - execv(argv[0], (char *const *)&argv[0]); - - // If execv returns, it failed. - assert(0 && "execv() failed"); - } - // This is run by the parent. - int child_status; - pid_t tpid; - do { // Wait for the child to terminate. - tpid = wait(&child_status); - } while (tpid != child_pid); - + llvm::sys::Program::ExecuteAndWait(llvm::sys::Path(argv[0]), &argv[0]); + // Finally, we create the translation unit from the ast file. ASTUnit *ATU = static_cast<ASTUnit *>( clang_createTranslationUnit(CIdx, astTmpFile)); |