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

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 18194003: Implement redirect-stdout-on-close on Winows, to the 'NUL' device. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove redundant 'USE'/ 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 | « runtime/bin/eventhandler_win.h ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_win.cc
diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc
index 7c96ce88339311cd7978b0a451e2202a339880b3..f1257c3ce5054c900dbf047ba5ad14a4600be95e 100644
--- a/runtime/bin/eventhandler_win.cc
+++ b/runtime/bin/eventhandler_win.cc
@@ -11,6 +11,8 @@
#include <winsock2.h> // NOLINT
#include <ws2tcpip.h> // NOLINT
#include <mswsock.h> // NOLINT
+#include <io.h> // NOLINT
+#include <fcntl.h> // NOLINT
#include "bin/builtin.h"
#include "bin/dartutils.h"
@@ -326,6 +328,18 @@ bool FileHandle::IsClosed() {
}
+void FileHandle::DoClose() {
+ if (GetStdHandle(STD_OUTPUT_HANDLE) == handle_) {
+ int fd = _open("NUL", _O_WRONLY);
+ ASSERT(fd >= 0);
+ _dup2(fd, _fileno(stdout));
+ close(fd);
+ } else {
+ Handle::DoClose();
+ }
+}
+
+
void SocketHandle::HandleIssueError() {
int error = WSAGetLastError();
if (error == WSAECONNRESET) {
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698