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

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

Issue 8879053: Don't treat stdin from a terminal differently from piped input (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debugging code Created 9 years 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/eventhandler_macos.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 <errno.h> 5 #include <errno.h>
6 #include <poll.h> 6 #include <poll.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if ((pollfd->revents & POLLIN) != 0) { 236 if ((pollfd->revents & POLLIN) != 0) {
237 if (FDUtils::AvailableBytes(pollfd->fd) != 0) { 237 if (FDUtils::AvailableBytes(pollfd->fd) != 0) {
238 event_mask = (1 << kInEvent); 238 event_mask = (1 << kInEvent);
239 } else if (((pollfd->revents & POLLHUP) != 0)) { 239 } else if (((pollfd->revents & POLLHUP) != 0)) {
240 event_mask = (1 << kCloseEvent); 240 event_mask = (1 << kCloseEvent);
241 sd->MarkClosedRead(); 241 sd->MarkClosedRead();
242 } else if ((pollfd->revents & POLLERR) != 0) { 242 } else if ((pollfd->revents & POLLERR) != 0) {
243 event_mask = (1 << kErrorEvent); 243 event_mask = (1 << kErrorEvent);
244 } else { 244 } else {
245 if (sd->IsPipe()) { 245 if (sd->IsPipe()) {
246 // For stdin when reading from a terminal treat POLLIN with 0 246 // When reading from stdin (either from a terminal or piped
247 // available bytes as end-of-file. 247 // input) treat POLLIN with 0 available bytes as
248 if (sd->fd() == STDIN_FILENO && isatty(sd->fd())) { 248 // end-of-file.
249 if (sd->fd() == STDIN_FILENO) {
249 event_mask = (1 << kCloseEvent); 250 event_mask = (1 << kCloseEvent);
250 sd->MarkClosedRead(); 251 sd->MarkClosedRead();
251 } 252 }
252 } else { 253 } else {
253 // If POLLIN is set with no available data and no POLLHUP use 254 // If POLLIN is set with no available data and no POLLHUP use
254 // recv to peek for whether the other end of the socket 255 // recv to peek for whether the other end of the socket
255 // actually closed. 256 // actually closed.
256 char buffer; 257 char buffer;
257 ssize_t bytesPeeked = recv(sd->fd(), &buffer, 1, MSG_PEEK); 258 ssize_t bytesPeeked = recv(sd->fd(), &buffer, 1, MSG_PEEK);
258 if (bytesPeeked == 0) { 259 if (bytesPeeked == 0) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 FATAL("Create start event handler thread"); 371 FATAL("Create start event handler thread");
371 } 372 }
372 } 373 }
373 374
374 375
375 void EventHandlerImplementation::SendData(intptr_t id, 376 void EventHandlerImplementation::SendData(intptr_t id,
376 Dart_Port dart_port, 377 Dart_Port dart_port,
377 intptr_t data) { 378 intptr_t data) {
378 WakeupHandler(id, dart_port, data); 379 WakeupHandler(id, dart_port, data);
379 } 380 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698