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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | runtime/bin/eventhandler_linux.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_android.cc
diff --git a/runtime/bin/eventhandler_android.cc b/runtime/bin/eventhandler_android.cc
index bbc8acbc8bec5ea726fc780a7cb6b62bb49d7e20..b716623b67c8aaad1e019c2590a892b8059e5ace 100644
--- a/runtime/bin/eventhandler_android.cc
+++ b/runtime/bin/eventhandler_android.cc
@@ -215,7 +215,12 @@ void EventHandlerImplementation::HandleInterruptFd() {
// next message.
RemoveFromEpollInstance(epoll_fd_, sd);
intptr_t fd = sd->fd();
- sd->Close();
+ if (fd == STDOUT_FILENO) {
+ // If stdout, redirect fd to /dev/null.
+ 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!
+ } 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.
+ sd->Close();
+ }
socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
delete sd;
} else {
« 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