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

Unified Diff: runtime/bin/socket_stream_impl.dart

Issue 9348050: Fix problem with socket input stream on MacOS when reading from tty. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_stream_impl.dart
diff --git a/runtime/bin/socket_stream_impl.dart b/runtime/bin/socket_stream_impl.dart
index 495104f4c61bf2fb426728e18541f2071ff44e58..d04c41bfb439a1b3ac53665e3a8e7402738ca10f 100644
--- a/runtime/bin/socket_stream_impl.dart
+++ b/runtime/bin/socket_stream_impl.dart
@@ -19,7 +19,13 @@ class _SocketInputStream implements SocketInputStream {
}
ByteArray buffer = new ByteArray(bytesToRead);
int bytesRead = _socket.readList(buffer, 0, bytesToRead);
- if (bytesRead < bytesToRead) {
+ if (bytesRead == 0) {
+ // On MacOS when reading from a tty Ctrl-D will result in one
+ // byte reported as available. Attempting to read it out will
+ // result in zero bytes read. When that happens there is no data
+ // which is indicated by a null return value.
+ return null;
+ } else if (bytesRead < bytesToRead) {
ByteArray newBuffer = new ByteArray(bytesRead);
newBuffer.setRange(0, bytesRead, buffer);
return newBuffer;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698