summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-10-29 16:39:01 +0000
committerDan Gohman <gohman@apple.com>2010-10-29 16:39:01 +0000
commitcae3c53b31ab42b69ee76438630084ebca8caea1 (patch)
treeb95840c0685c5dac019cea816e26622a63f1c438 /llvm/lib/System
parent8682b69b81b802232f4b1c81270ff0ecb4b4353a (diff)
downloadbcm5719-llvm-cae3c53b31ab42b69ee76438630084ebca8caea1.tar.gz
bcm5719-llvm-cae3c53b31ab42b69ee76438630084ebca8caea1.zip
Make Program::Wait provide an error message string for errors
executing the child process and abnormal child process termination. llvm-svn: 117661
Diffstat (limited to 'llvm/lib/System')
-rw-r--r--llvm/lib/System/Unix/Program.inc28
1 files changed, 19 insertions, 9 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 110a6d14f48..76012afcbaa 100644
--- a/llvm/lib/System/Unix/Program.inc
+++ b/llvm/lib/System/Unix/Program.inc
@@ -350,22 +350,32 @@ Program::Wait(unsigned secondsToWait,
sigaction(SIGALRM, &Old, 0);
}
- // Return the proper exit status. 0=success, >0 is programs' exit status,
- // <0 means a signal was returned, -9999999 means the program dumped core.
+ // Return the proper exit status. Detect error conditions
+ // so we can return -1 for them and set ErrMsg informatively.
int result = 0;
- if (WIFEXITED(status))
+ if (WIFEXITED(status)) {
result = WEXITSTATUS(status);
- else if (WIFSIGNALED(status))
- result = 0 - WTERMSIG(status);
+ if (result == 127) {
+ *ErrMsg = llvm::sys::StrError(ENOENT);
+ return -1;
+ }
+ if (result == 126) {
+ *ErrMsg = "Program could not be executed";
+ return -1;
+ }
+ } else if (WIFSIGNALED(status)) {
+ *ErrMsg = strsignal(WTERMSIG(status));
#ifdef WCOREDUMP
- else if (WCOREDUMP(status))
- result |= 0x01000000;
+ if (WCOREDUMP(status))
+ *ErrMsg += " (core dumped)";
#endif
+ return -1;
+ }
return result;
#else
- return -99;
+ *ErrMsg = "Program::Wait is not implemented on this platform yet!";
+ return -1;
#endif
-
}
bool
OpenPOWER on IntegriCloud