summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Program.inc
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-06-12 12:53:35 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-06-12 12:53:35 +0000
commit1cc695efd710e32eff06a336cb5391c52488cd2c (patch)
tree457c700aedd8ef09728c2917016dde6d27d42f6b /llvm/lib/System/Unix/Program.inc
parentcaec17eab9955a9a4558f0d3000eb336f494220e (diff)
downloadbcm5719-llvm-1cc695efd710e32eff06a336cb5391c52488cd2c.tar.gz
bcm5719-llvm-1cc695efd710e32eff06a336cb5391c52488cd2c.zip
Fix redirection of stderr in sys::Program::ExecuteAndWait. There was logic
error that caused it to redirect stderr to stdout too often. This fix is applied identically to the win32 code as well, but that is untested. --Thi line, and those below, will be ignored-- M System/Unix/Program.inc M System/Win32/Program.inc llvm-svn: 52233
Diffstat (limited to 'llvm/lib/System/Unix/Program.inc')
-rw-r--r--llvm/lib/System/Unix/Program.inc15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 6ff69ca133e..2426900578b 100644
--- a/llvm/lib/System/Unix/Program.inc
+++ b/llvm/lib/System/Unix/Program.inc
@@ -170,14 +170,21 @@ Program::ExecuteAndWait(const Path& path,
case 0: {
// Redirect file descriptors...
if (redirects) {
+ // Redirect stdin
if (RedirectIO(redirects[0], 0, ErrMsg)) { return -1; }
+ // Redirect stdout
if (RedirectIO(redirects[1], 1, ErrMsg)) { return -1; }
if (redirects[1] && redirects[2] &&
- *(redirects[1]) != *(redirects[2])) {
+ *(redirects[1]) == *(redirects[2])) {
+ // If stdout and stderr should go to the same place, redirect stderr
+ // to the FD already open for stdout.
+ if (-1 == dup2(1,2)) {
+ MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout");
+ return -1;
+ }
+ } else {
+ // Just redirect stderr
if (RedirectIO(redirects[2], 2, ErrMsg)) { return -1; }
- } else if (-1 == dup2(1,2)) {
- MakeErrMsg(ErrMsg, "Can't redirect");
- return -1;
}
}
OpenPOWER on IntegriCloud