http://llvm.org/bugs/show_bug.cgi?id=22659
Bug ID: 22659
Summary: llvm::sys::ExecuteAndWait does not truncate redirected
output
Product: libraries
Version: 3.6
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Support Libraries
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
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().
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs