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

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

Issue 18031003: Stop printing when stdout is closed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use dup2 Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) { 228 } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) {
229 ASSERT(msg.data == (1 << kShutdownWriteCommand)); 229 ASSERT(msg.data == (1 << kShutdownWriteCommand));
230 // Close the socket for writing. 230 // Close the socket for writing.
231 sd->ShutdownWrite(); 231 sd->ShutdownWrite();
232 UpdateKqueue(kqueue_fd_, sd); 232 UpdateKqueue(kqueue_fd_, sd);
233 } else if ((msg.data & (1 << kCloseCommand)) != 0) { 233 } else if ((msg.data & (1 << kCloseCommand)) != 0) {
234 ASSERT(msg.data == (1 << kCloseCommand)); 234 ASSERT(msg.data == (1 << kCloseCommand));
235 // Close the socket and free system resources. 235 // Close the socket and free system resources.
236 RemoveFromKqueue(kqueue_fd_, sd); 236 RemoveFromKqueue(kqueue_fd_, sd);
237 intptr_t fd = sd->fd(); 237 intptr_t fd = sd->fd();
238 sd->Close(); 238 if (fd == STDOUT_FILENO) {
239 // If stdout, redirect fd to /dev/null.
240 USE(dup2(open("/dev/null", O_WRONLY), STDOUT_FILENO));
241 } else {
242 sd->Close();
243 }
239 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 244 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
240 delete sd; 245 delete sd;
241 } else { 246 } else {
242 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { 247 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) {
243 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); 248 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent);
244 } else { 249 } else {
245 // Setup events to wait for. 250 // Setup events to wait for.
246 sd->SetPortAndMask(msg.dart_port, msg.data); 251 sd->SetPortAndMask(msg.dart_port, msg.data);
247 UpdateKqueue(kqueue_fd_, sd); 252 UpdateKqueue(kqueue_fd_, sd);
248 } 253 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 442
438 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 443 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
439 // The hashmap does not support keys with value 0. 444 // The hashmap does not support keys with value 0.
440 return dart::Utils::WordHash(fd + 1); 445 return dart::Utils::WordHash(fd + 1);
441 } 446 }
442 447
443 } // namespace bin 448 } // namespace bin
444 } // namespace dart 449 } // namespace dart
445 450
446 #endif // defined(TARGET_OS_MACOS) 451 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698