summaryrefslogtreecommitdiff
path: root/lib/Support/SystemUtils.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-27 01:20:55 +0000
committerChris Lattner <sabre@nondot.org>2004-05-27 01:20:55 +0000
commitd895ffe122269dd577d98dee4a82f8ea15029b30 (patch)
treea0079be3f7deaa9751c9b8b69ffe768f590d6f6f /lib/Support/SystemUtils.cpp
parent9a5dc4f7e5821a211eb0c7d04c0afcb8c7d58ee0 (diff)
downloadllvm-d895ffe122269dd577d98dee4a82f8ea15029b30.tar.gz
llvm-d895ffe122269dd577d98dee4a82f8ea15029b30.tar.bz2
llvm-d895ffe122269dd577d98dee4a82f8ea15029b30.tar.xz
Changes to make libSupport build on systems that don't have the wait syscall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13806 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SystemUtils.cpp')
-rw-r--r--lib/Support/SystemUtils.cpp42
1 files changed, 12 insertions, 30 deletions
diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp
index a39c5ab52f..398096a6a6 100644
--- a/lib/Support/SystemUtils.cpp
+++ b/lib/Support/SystemUtils.cpp
@@ -134,6 +134,7 @@ int llvm::RunProgramWithTimeout(const std::string &ProgramPath,
const std::string &StdErrFile) {
// FIXME: install sigalarm handler here for timeout...
+#ifdef HAVE_SYS_WAIT_H
int Child = fork();
switch (Child) {
case -1:
@@ -179,6 +180,11 @@ int llvm::RunProgramWithTimeout(const std::string &ProgramPath,
exit(1);
}
return Status;
+
+#else
+ std::cerr << "RunProgramWithTimeout not implemented on this platform!\n";
+ return -1;
+#endif
}
@@ -220,12 +226,7 @@ int llvm::RunProgramWithTimeout(const std::string &ProgramPath,
//
int llvm::ExecWait(const char * const old_argv[],
const char * const old_envp[]) {
- // Child process ID
- register int child;
-
- // Status from child process when it exits
- int status;
-
+#ifdef HAVE_SYS_WAIT_H
//
// Create local versions of the parameters that can be passed into execve()
// without creating const problems.
@@ -233,56 +234,37 @@ int llvm::ExecWait(const char * const old_argv[],
char ** const argv = (char ** const) old_argv;
char ** const envp = (char ** const) old_envp;
- //
// Create a child process.
- //
- switch (child=fork())
- {
- //
+ switch (fork()) {
// An error occured: Return to the caller.
- //
case -1:
return 1;
break;
- //
// Child process: Execute the program.
- //
case 0:
execve (argv[0], argv, envp);
-
- //
// If the execve() failed, we should exit and let the parent pick up
// our non-zero exit status.
- //
exit (1);
- break;
- //
// Parent process: Break out of the switch to do our processing.
- //
default:
break;
}
- //
// Parent process: Wait for the child process to termiante.
- //
+ int status;
if ((wait (&status)) == -1)
- {
return 1;
- }
- //
// If the program exited normally with a zero exit status, return success!
- //
if (WIFEXITED (status) && (WEXITSTATUS(status) == 0))
- {
return 0;
- }
+#else
+ std::cerr << "llvm::ExecWait not implemented on this platform!\n";
+#endif
- //
// Otherwise, return failure.
- //
return 1;
}