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

Side by Side Diff: runtime/bin/socket_patch.dart

Issue 17463003: Detect EOF when reading stdio from terminal on Mac OS (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed tabs Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 1017
1018 void _onPauseStateChange() { 1018 void _onPauseStateChange() {
1019 if (_raw != null) { 1019 if (_raw != null) {
1020 _raw.readEventsEnabled = !_controller.isPaused; 1020 _raw.readEventsEnabled = !_controller.isPaused;
1021 } 1021 }
1022 } 1022 }
1023 1023
1024 void _onData(event) { 1024 void _onData(event) {
1025 switch (event) { 1025 switch (event) {
1026 case RawSocketEvent.READ: 1026 case RawSocketEvent.READ:
1027 var buffer = _raw.read(); 1027 // On Mac OS the end of file on stdin, when connected to a terminal,
1028 if (buffer != null) _controller.add(buffer); 1028 // is detected by readling less bytes than available on the socket. A
1029 // Ctrl-D does not generate a read close event.
1030 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
1031 var available = _raw.available();
1032 if (available == 0) return;
1033 var buffer = _raw.read();
1034 if (buffer != null) _controller.add(buffer);
1035 // If less bytes than available was read this is end of file.
1036 if (buffer == null || buffer.length < available) {
1037 _controllerClosed = true;
1038 _controller.close();
1039 }
1040 } else {
1041 var buffer = _raw.read();
1042 if (buffer != null) _controller.add(buffer);
1043 }
1029 break; 1044 break;
1030 case RawSocketEvent.WRITE: 1045 case RawSocketEvent.WRITE:
1031 _consumer.write(); 1046 _consumer.write();
1032 break; 1047 break;
1033 case RawSocketEvent.READ_CLOSED: 1048 case RawSocketEvent.READ_CLOSED:
1034 _controllerClosed = true; 1049 _controllerClosed = true;
1035 _controller.close(); 1050 _controller.close();
1036 break; 1051 break;
1037 } 1052 }
1038 } 1053 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 if (_detachReady != null) { 1086 if (_detachReady != null) {
1072 _detachReady.complete(null); 1087 _detachReady.complete(null);
1073 } else { 1088 } else {
1074 if (_raw != null) { 1089 if (_raw != null) {
1075 _raw.shutdown(SocketDirection.SEND); 1090 _raw.shutdown(SocketDirection.SEND);
1076 _disableWriteEvent(); 1091 _disableWriteEvent();
1077 } 1092 }
1078 } 1093 }
1079 } 1094 }
1080 } 1095 }
OLDNEW
« 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