[LLVMbugs] [Bug 18869] New: ExecuteAndWait fails when called second time on OSX
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Feb 17 07:53:10 PST 2014
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: unassignedbugs at nondot.org
Reporter: elviss at elviss.lv
CC: llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140217/77ef7836/attachment.html>
More information about the llvm-bugs
mailing list