Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: runtime/bin/process_macos.cc

Issue 23076002: Fix Process.runSync on 64-bit Mac OS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_macos.cc
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
index 1d08cacf8cec9f5592680e97b7fe7c5574ec7ac2..78d3cdb5f49f8a741e1a3a8348cdfbf42d389122 100644
--- a/runtime/bin/process_macos.cc
+++ b/runtime/bin/process_macos.cc
@@ -575,8 +575,8 @@ class BufferList: public BufferListBase {
if (free_size_ == 0) Allocate();
ASSERT(free_size_ > 0);
ASSERT(free_size_ <= kBufferSize);
- intptr_t block_size = dart::Utils::Minimum(free_size_, available);
- intptr_t bytes = TEMP_FAILURE_RETRY(read(
+ size_t block_size = dart::Utils::Minimum(free_size_, available);
+ ssize_t bytes = TEMP_FAILURE_RETRY(read(
fd,
reinterpret_cast<void*>(FreeSpaceAddress()),
block_size));
@@ -636,9 +636,11 @@ bool Process::Wait(intptr_t pid,
}
// Process incoming data.
- for (int i = 0; i < alive; i++) {
+ int current_alive = alive;
+ for (int i = 0; i < current_alive; i++) {
+ intptr_t avail;
if (fds[i].revents & POLLIN) {
- intptr_t avail = FDUtils::AvailableBytes(fds[i].fd);
+ avail = FDUtils::AvailableBytes(fds[i].fd);
// On Mac OS POLLIN can be set with zero available
// bytes. POLLHUP is most likely also set in this case.
if (avail > 0) {
@@ -663,11 +665,8 @@ bool Process::Wait(intptr_t pid,
}
}
}
- }
-
- // Process closed.
- for (int i = 0; i < alive; i++) {
- if (fds[i].revents & POLLHUP) {
+ if (fds[i].revents & POLLHUP ||
+ ((fds[i].revents & POLLIN) && avail == 0)) {
VOID_TEMP_FAILURE_RETRY(close(fds[i].fd));
alive--;
if (i < alive) {
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698