OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/devfs/tty_node.h" | 5 #include "nacl_io/devfs/tty_node.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 Error TtyNode::Read(const HandleAttr& attr, | 104 Error TtyNode::Read(const HandleAttr& attr, |
105 void* buf, | 105 void* buf, |
106 size_t count, | 106 size_t count, |
107 int* out_bytes) { | 107 int* out_bytes) { |
108 EventListenerLock wait(GetEventEmitter()); | 108 EventListenerLock wait(GetEventEmitter()); |
109 *out_bytes = 0; | 109 *out_bytes = 0; |
110 | 110 |
111 // If interrupted, return | 111 // If interrupted, return |
112 Error err = wait.WaitOnEvent(POLLIN, -1); | 112 Error err = wait.WaitOnEvent(POLLIN, -1); |
| 113 if (err == ETIMEDOUT) |
| 114 err = EWOULDBLOCK; |
113 if (err != 0) | 115 if (err != 0) |
114 return err; | 116 return err; |
115 | 117 |
116 size_t bytes_to_copy = std::min(count, input_buffer_.size()); | 118 size_t bytes_to_copy = std::min(count, input_buffer_.size()); |
117 if (IS_ICANON) { | 119 if (IS_ICANON) { |
118 // Only read up to (and including) the first newline | 120 // Only read up to (and including) the first newline |
119 std::deque<char>::iterator nl = | 121 std::deque<char>::iterator nl = |
120 std::find(input_buffer_.begin(), input_buffer_.end(), '\n'); | 122 std::find(input_buffer_.begin(), input_buffer_.end(), '\n'); |
121 | 123 |
122 if (nl != input_buffer_.end()) { | 124 if (nl != input_buffer_.end()) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 290 } |
289 | 291 |
290 Error TtyNode::Tcsetattr(int optional_actions, | 292 Error TtyNode::Tcsetattr(int optional_actions, |
291 const struct termios* termios_p) { | 293 const struct termios* termios_p) { |
292 AUTO_LOCK(node_lock_); | 294 AUTO_LOCK(node_lock_); |
293 termios_ = *termios_p; | 295 termios_ = *termios_p; |
294 return 0; | 296 return 0; |
295 } | 297 } |
296 | 298 |
297 } // namespace nacl_io | 299 } // namespace nacl_io |
OLD | NEW |