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

Side by Side Diff: runtime/bin/stdin_android.cc

Issue 24315008: Make stdin blocking when using Stdin::readByte and readLine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | runtime/bin/stdin_linux.cc » ('j') | 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include <termios.h> // NOLINT 8 #include <termios.h> // NOLINT
9 9
10 #include "bin/stdin.h" 10 #include "bin/stdin.h"
11 #include "bin/fdutils.h"
11 12
12 13
13 namespace dart { 14 namespace dart {
14 namespace bin { 15 namespace bin {
15 16
16 int Stdin::ReadByte() { 17 int Stdin::ReadByte() {
18 FDUtils::SetBlocking(fileno(stdin));
17 int c = getchar(); 19 int c = getchar();
18 if (c == EOF) { 20 if (c == EOF) {
19 c = -1; 21 c = -1;
20 } 22 }
23 FDUtils::SetNonBlocking(fileno(stdin));
21 return c; 24 return c;
22 } 25 }
23 26
24 27
25 void Stdin::SetEchoMode(bool enabled) { 28 void Stdin::SetEchoMode(bool enabled) {
26 struct termios term; 29 struct termios term;
27 tcgetattr(fileno(stdin), &term); 30 tcgetattr(fileno(stdin), &term);
28 if (enabled) { 31 if (enabled) {
29 term.c_lflag |= ECHO|ECHONL; 32 term.c_lflag |= ECHO|ECHONL;
30 } else { 33 } else {
(...skipping 12 matching lines...) Expand all
43 term.c_lflag &= ~(ICANON); 46 term.c_lflag &= ~(ICANON);
44 } 47 }
45 tcsetattr(fileno(stdin), TCSANOW, &term); 48 tcsetattr(fileno(stdin), TCSANOW, &term);
46 } 49 }
47 50
48 } // namespace bin 51 } // namespace bin
49 } // namespace dart 52 } // namespace dart
50 53
51 #endif // defined(TARGET_OS_ANDROID) 54 #endif // defined(TARGET_OS_ANDROID)
52 55
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/stdin_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698