aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Unix/Program.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Unix/Program.inc')
-rw-r--r--lib/Support/Unix/Program.inc24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc
index e5990d06ec..049c41b742 100644
--- a/lib/Support/Unix/Program.inc
+++ b/lib/Support/Unix/Program.inc
@@ -103,6 +103,10 @@ Program::FindProgramByName(const std::string& progName) {
}
static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) {
+#if defined(__native_client__)
+ MakeErrMsg(ErrMsg, "Cannot redirect I/O in NaCl");
+ return true;
+#else // (__native_client__)
if (Path == 0) // Noop
return false;
const char *File;
@@ -119,7 +123,6 @@ static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) {
+ (FD == 0 ? "input" : "output"));
return true;
}
-
// Install it as the requested FD
if (dup2(InFD, FD) == -1) {
MakeErrMsg(ErrMsg, "Cannot dup2");
@@ -128,6 +131,7 @@ static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) {
}
close(InFD); // Close the original FD
return false;
+#endif // (__native_client__)
}
#ifdef HAVE_POSIX_SPAWN
@@ -233,6 +237,7 @@ Program::Execute(const Path &path, const char **args, const char **envp,
}
#endif
+#if !defined(__native_client__)
// Create a child process.
int child = fork();
switch (child) {
@@ -293,6 +298,10 @@ Program::Execute(const Path &path, const char **args, const char **envp,
Data_ = reinterpret_cast<void*>(child);
return true;
+#else // (__native_client__)
+ MakeErrMsg(ErrMsg, "PNACL does not know how to execute child processes!");
+ return false;
+#endif // (__native_client__)
}
int
@@ -300,6 +309,7 @@ Program::Wait(const sys::Path &path,
unsigned secondsToWait,
std::string* ErrMsg)
{
+#if !defined(__native_client__)
#ifdef HAVE_SYS_WAIT_H
struct sigaction Act, Old;
@@ -392,10 +402,16 @@ Program::Wait(const sys::Path &path,
*ErrMsg = "Program::Wait is not implemented on this platform yet!";
return -1;
#endif
+#else // (__native_client__)
+// TODO(abetul): What should the proper return value be here?
+ MakeErrMsg(ErrMsg, "PNACL does not know how to wait for a child process!");
+ return -1;
+#endif // (__native_client__)
}
bool
Program::Kill(std::string* ErrMsg) {
+#if !defined(__native_client__)
if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return true;
@@ -410,6 +426,12 @@ Program::Kill(std::string* ErrMsg) {
}
return false;
+
+#else // (__native_client__)
+ MakeErrMsg(ErrMsg, "PNACL does not know how to kill processes!");
+ return true;
+#endif // (__native_client__)
+
}
error_code Program::ChangeStdinToBinary(){