1 //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains functions used to do a variety of low-level, often
11 // system-specific, tasks.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_SYSTEMUTILS_H
16 #define LLVM_SUPPORT_SYSTEMUTILS_H
18 #include "llvm/System/Path.h"
22 /// isStandardOutAConsole - Return true if we can tell that the standard output
23 /// stream goes to a terminal window or console.
24 bool isStandardOutAConsole();
26 /// FindExecutable - Find a named executable, giving the argv[0] of program
27 /// being executed. This allows us to find another LLVM tool if it is built into
28 /// the same directory, but that directory is neither the current directory, nor
29 /// in the PATH. If the executable cannot be found, return an empty string.
31 sys::Path FindExecutable(const std::string &ExeName,
32 const std::string &ProgramPath);
34 /// RunProgramWithTimeout - This function executes the specified program, with
35 /// the specified null-terminated argument array, with the stdin/out/err fd's
36 /// redirected, with a timeout specified by the last argument. This terminates
37 /// the calling program if there is an error executing the specified program.
38 /// It returns the return value of the program, or -1 if a timeout is detected.
40 int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
41 const std::string &StdInFile = "",
42 const std::string &StdOutFile = "",
43 const std::string &StdErrFile = "",
44 unsigned NumSeconds = 0);
46 /// ExecWait - Execute a program with the given arguments and environment and
47 /// wait for it to terminate.
49 int ExecWait (const char * const argv[], const char * const envp[]);
51 } // End llvm namespace