Chromium Code Reviews| Index: runtime/bin/socket_patch.dart |
| diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart |
| index d9886117023cf22f8eee06128db1f09f727474c6..97e8195a8ef094cf182d518f33dc129365d43b9a 100644 |
| --- a/runtime/bin/socket_patch.dart |
| +++ b/runtime/bin/socket_patch.dart |
| @@ -1024,8 +1024,23 @@ class _Socket extends Stream<List<int>> implements Socket { |
| void _onData(event) { |
| switch (event) { |
| case RawSocketEvent.READ: |
| - var buffer = _raw.read(); |
| - if (buffer != null) _controller.add(buffer); |
| + // On Mac OS the end of file on stdin, when connected to a terminal, |
| + // is detected by readling less bytes than available on the socket. A |
| + // Ctrl-D does not generate a read close event. |
| + if (Platform.operatingSystem == "macos") { |
|
Anders Johnsen
2013/06/20 12:10:48
Platform.isMacos :)
Søren Gjesse
2013/06/25 10:17:41
Done (that was actually why I added isMacOS to Pla
|
| + var available = _raw.available(); |
| + if (available == 0) return; |
| + var buffer = _raw.read(); |
| + if (buffer != null) _controller.add(buffer); |
| + // If less bytes than available was read this is end of file. |
| + if (buffer == null || buffer.length < available) { |
| + _controllerClosed = true; |
| + _controller.close(); |
| + } |
| + } else { |
| + var buffer = _raw.read(); |
| + if (buffer != null) _controller.add(buffer); |
| + } |
| break; |
| case RawSocketEvent.WRITE: |
| _consumer.write(); |