http://llvm.org/bugs/show_bug.cgi?id=18869
Bug ID: 18869
Summary: ExecuteAndWait fails when called second time on OSX
Product: libraries
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Support Libraries
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
The second call to ExecuteAndWait returns -1, because Wait sets ChildPid to -1,
and catches EINTR the first time it is called. Subsequent Wait calls return pid
of previous processes and fail.
The following code produces the error on OSX, no problems for other platforms.
int main()
{
const char* args0[] = { "/bin/ls", NULL};
std::cout << llvm::sys::ExecuteAndWait(args0[0], args0) << "\n";
//wait until the first one finishes
sleep(1);
const char* args1[] = { "/bin/pwd", NULL};
std::cout << llvm::sys::ExecuteAndWait(args1[0], args1) << "\n";
return 0;
}
Commenting line 335 in /lib/Support/Unix/Program.inc (ChildPid = -1; // mimic a
wait() using waitpid()) fixes the problem and I think it is OK to wait only for
the launched process not for any process to finish. LLVM 3.3 was looping until
waitpid returned the correct pid, that way Wait also works correctly.
--
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