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

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: Add include for all platforms and don't leak fds. 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') | no next file with comments »
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..74fb5da5c3e294492a5e535401e9eb9b019667f8 100644
--- a/runtime/bin/eventhandler_android.cc
+++ b/runtime/bin/eventhandler_android.cc
@@ -14,6 +14,7 @@
#include <sys/epoll.h> // NOLINT
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
+#include <fcntl.h> // NOLINT
#include "bin/dartutils.h"
#include "bin/fdutils.h"
@@ -215,7 +216,15 @@ 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.
+ int null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY));
+ ASSERT(null_fd >= 0);
+ VOID_TEMP_FAILURE_RETRY(dup2(null_fd, STDOUT_FILENO));
Bill Hesse 2013/06/27 16:42:36 OK, so stdout is still open at this point, so we k
+ VOID_TEMP_FAILURE_RETRY(close(null_fd));
+ } else {
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698