aboutsummaryrefslogtreecommitdiff
path: root/lib/System/Unix/Program.inc
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-12-22 20:00:16 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-12-22 20:00:16 +0000
commitd555f413cddb554203e3584047116fd97f6383d6 (patch)
tree8cc378a3fd2cf5e9956700c3aded044668424661 /lib/System/Unix/Program.inc
parent171eee54717a22f439b06a4e07b361fcd983af1f (diff)
For PR351:
* Allow the ExecuteAndWait to return negative values if a signal is detected as the reason for the child termination. This is needed to support bugpoint detecting bad things in its child processes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Program.inc')
-rw-r--r--lib/System/Unix/Program.inc19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index 8aa0705726..47810bdbeb 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -209,17 +209,22 @@ Program::ExecuteAndWait(const Path& path,
sigaction(SIGALRM, &Old, 0);
}
- // If the program exited normally with a zero exit status, return success!
+ // Return the proper exit status. 0=success, >0 is programs' exit status,
+ // <0 means a signal was returned, -9999999 means the program dumped core.
+ int result = 0;
if (WIFEXITED (status))
- return WEXITSTATUS(status);
+ result = WEXITSTATUS(status);
else if (WIFSIGNALED(status))
- return 1;
-
+ result = 0 - WTERMSIG(status);
+#ifdef WCOREDUMP
+ if (WCOREDUMP(status))
+ result |= 0x01000000;
+#endif
+ return result;
#else
- throw std::string(
- "Program::ExecuteAndWait not implemented on this platform!\n");
+ return -99;
#endif
- return 0;
+
}
}