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

Side by Side Diff: runtime/bin/eventhandler_android.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
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | runtime/bin/eventhandler_linux.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ASSERT(msg.data == (1 << kShutdownWriteCommand)); 208 ASSERT(msg.data == (1 << kShutdownWriteCommand));
209 // Close the socket for writing. 209 // Close the socket for writing.
210 sd->ShutdownWrite(); 210 sd->ShutdownWrite();
211 UpdateEpollInstance(epoll_fd_, sd); 211 UpdateEpollInstance(epoll_fd_, sd);
212 } else if ((msg.data & (1 << kCloseCommand)) != 0) { 212 } else if ((msg.data & (1 << kCloseCommand)) != 0) {
213 ASSERT(msg.data == (1 << kCloseCommand)); 213 ASSERT(msg.data == (1 << kCloseCommand));
214 // Close the socket and free system resources and move on to 214 // Close the socket and free system resources and move on to
215 // next message. 215 // next message.
216 RemoveFromEpollInstance(epoll_fd_, sd); 216 RemoveFromEpollInstance(epoll_fd_, sd);
217 intptr_t fd = sd->fd(); 217 intptr_t fd = sd->fd();
218 sd->Close(); 218 if (fd == STDOUT_FILENO) {
219 // If stdout, redirect fd to /dev/null.
220 USE(dup2(open("/dev/null", O_WRONLY), STDOUT_FILENO));
kustermann 2013/06/27 15:14:07 You leak one file descriptor here. I'd do somethin
Anders Johnsen 2013/06/27 16:32:07 You're right, thanks!
221 } else {
Bill Hesse 2013/06/27 16:42:36 Shouldn't you be checking that dev/null didn't ope
Anders Johnsen 2013/06/27 16:44:11 No, it's still open at this point.
222 sd->Close();
223 }
219 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 224 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
220 delete sd; 225 delete sd;
221 } else { 226 } else {
222 // Setup events to wait for. 227 // Setup events to wait for.
223 sd->SetPortAndMask(msg.dart_port, msg.data); 228 sd->SetPortAndMask(msg.dart_port, msg.data);
224 UpdateEpollInstance(epoll_fd_, sd); 229 UpdateEpollInstance(epoll_fd_, sd);
225 } 230 }
226 } 231 }
227 } 232 }
228 } 233 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 432
428 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 433 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
429 // The hashmap does not support keys with value 0. 434 // The hashmap does not support keys with value 0.
430 return dart::Utils::WordHash(fd + 1); 435 return dart::Utils::WordHash(fd + 1);
431 } 436 }
432 437
433 } // namespace bin 438 } // namespace bin
434 } // namespace dart 439 } // namespace dart
435 440
436 #endif // defined(TARGET_OS_ANDROID) 441 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | runtime/bin/eventhandler_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698