<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - llvm::sys::ExecuteAndWait does not truncate redirected output"
href="http://llvm.org/bugs/show_bug.cgi?id=22659">22659</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm::sys::ExecuteAndWait does not truncate redirected output
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Support Libraries
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pohilets@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code snippet reproduces the problem:
#include <llvm/Support/Program.h>
int main(int argc, const char * argv[]) {
if (argc == 1) {
// Parent process
char const * args[] = { argv[0], "foooooo", nullptr };
llvm::StringRef out("test.txt");
const llvm::StringRef* redirects[] = { nullptr, &out, nullptr };
llvm::sys::ExecuteAndWait(argv[0], args, nullptr, redirects);
args[1] = "xxx";
llvm::sys::ExecuteAndWait(argv[0], args, nullptr, redirects);
} else {
// Child process
printf("%s\n", argv[1]);
}
return 0;
}
Actual content of 'test.txt':
xxx
ooo
Expected content of 'test.txt':
xxx
LLVM is compiled with HAVE_POSIX_SPAWN - redirect is done in function
RedirectIO_PS.
Seems that this can be fixed by simply adding O_TRUNC to opening flags in
RedirectIO_PS() and RedirectIO().</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>