For PR351:

Replace RunProgramWithTimeout with an inline function that calls
sys::Program::ExecuteAndWait. This is now just a convenience function.

llvm-svn: 19037
This commit is contained in:
Reid Spencer 2004-12-19 17:59:33 +00:00
parent 033fed0205
commit fb741b2700
1 changed files with 20 additions and 19 deletions

View File

@ -15,7 +15,7 @@
#ifndef LLVM_SUPPORT_SYSTEMUTILS_H #ifndef LLVM_SUPPORT_SYSTEMUTILS_H
#define LLVM_SUPPORT_SYSTEMUTILS_H #define LLVM_SUPPORT_SYSTEMUTILS_H
#include "llvm/System/Path.h" #include "llvm/System/Program.h"
namespace llvm { namespace llvm {
@ -27,26 +27,27 @@ bool isStandardOutAConsole();
/// being executed. This allows us to find another LLVM tool if it is built into /// being executed. This allows us to find another LLVM tool if it is built into
/// the same directory, but that directory is neither the current directory, nor /// the same directory, but that directory is neither the current directory, nor
/// in the PATH. If the executable cannot be found, return an empty string. /// in the PATH. If the executable cannot be found, return an empty string.
/// /// @brief Find a named executable.
sys::Path FindExecutable(const std::string &ExeName, sys::Path FindExecutable(const std::string &ExeName,
const std::string &ProgramPath); const std::string &ProgramPath);
/// RunProgramWithTimeout - This function executes the specified program, with /// RunProgramWithTimeout - This function provides an alternate interface to the
/// the specified null-terminated argument array, with the stdin/out/err fd's /// sys::Program::ExecuteAndWait interface.
/// redirected, with a timeout specified by the last argument. This terminates /// @see sys:Program::ExecuteAndWait
/// the calling program if there is an error executing the specified program. inline int llvm::RunProgramWithTimeout(const sys::Path &ProgramPath,
/// It returns the return value of the program, or -1 if a timeout is detected. const char **Args,
/// const sys::Path &StdInFile,
int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, const sys::Path &StdOutFile,
const std::string &StdInFile = "", const sys::Path &StdErrFile,
const std::string &StdOutFile = "", unsigned NumSeconds = 0) {
const std::string &StdErrFile = "", const sys::Path* redirects[3];
unsigned NumSeconds = 0); redirects[0] = &StdInFile;
redirects[1] = &StdOutFile;
/// ExecWait - Execute a program with the given arguments and environment and redirects[2] = &StdErrFile;
/// wait for it to terminate.
/// return
int ExecWait (const char * const argv[], const char * const envp[]); sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds);
}
} // End llvm namespace } // End llvm namespace