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

Side by Side Diff: runtime/bin/eventhandler_macos.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 | « runtime/bin/eventhandler_linux.cc ('k') | 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) 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if ((pollfd->revents & POLLIN) != 0) { 234 if ((pollfd->revents & POLLIN) != 0) {
235 if (FDUtils::AvailableBytes(pollfd->fd) != 0) { 235 if (FDUtils::AvailableBytes(pollfd->fd) != 0) {
236 event_mask = (1 << kInEvent); 236 event_mask = (1 << kInEvent);
237 } else if (((pollfd->revents & POLLHUP) != 0)) { 237 } else if (((pollfd->revents & POLLHUP) != 0)) {
238 event_mask = (1 << kCloseEvent); 238 event_mask = (1 << kCloseEvent);
239 sd->MarkClosedRead(); 239 sd->MarkClosedRead();
240 } else if ((pollfd->revents & POLLERR) != 0) { 240 } else if ((pollfd->revents & POLLERR) != 0) {
241 event_mask = (1 << kErrorEvent); 241 event_mask = (1 << kErrorEvent);
242 } else { 242 } else {
243 if (sd->IsPipe()) { 243 if (sd->IsPipe()) {
244 // For stdin when reading from a terminal treat POLLIN with 0 244 // When reading from stdin (either from a terminal or piped
245 // available bytes as end-of-file. 245 // input) treat POLLIN with 0 available bytes as
246 if (sd->fd() == STDIN_FILENO && isatty(sd->fd())) { 246 // end-of-file.
247 if (sd->fd() == STDIN_FILENO) {
247 event_mask = (1 << kCloseEvent); 248 event_mask = (1 << kCloseEvent);
248 sd->MarkClosedRead(); 249 sd->MarkClosedRead();
249 } 250 }
250 } else { 251 } else {
251 // If POLLIN is set with no available data and no POLLHUP use 252 // If POLLIN is set with no available data and no POLLHUP use
252 // recv to peek for whether the other end of the socket 253 // recv to peek for whether the other end of the socket
253 // actually closed. 254 // actually closed.
254 char buffer; 255 char buffer;
255 ssize_t bytesPeeked = recv(sd->fd(), &buffer, 1, MSG_PEEK); 256 ssize_t bytesPeeked = recv(sd->fd(), &buffer, 1, MSG_PEEK);
256 if (bytesPeeked == 0) { 257 if (bytesPeeked == 0) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 FATAL("Create start event handler thread"); 369 FATAL("Create start event handler thread");
369 } 370 }
370 } 371 }
371 372
372 373
373 void EventHandlerImplementation::SendData(intptr_t id, 374 void EventHandlerImplementation::SendData(intptr_t id,
374 Dart_Port dart_port, 375 Dart_Port dart_port,
375 intptr_t data) { 376 intptr_t data) {
376 WakeupHandler(id, dart_port, data); 377 WakeupHandler(id, dart_port, data);
377 } 378 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698