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

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: 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..fdc35824dda5c1dd930cc1054ac44f476fba0d91 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);
kustermann 2013/06/28 10:10:14 Is this opening a file called "NUL" or an actual /
Anders Johnsen 2013/06/28 10:19:11 Yep, check out http://en.wikipedia.org/wiki/%5CDev
+ ASSERT(fd >= 0);
+ USE(_dup2(fd, _fileno(stdout)));
+ USE(close(fd));
kustermann 2013/06/28 10:10:14 AFAIK USE() is not necessary here. USE() is useful
Anders Johnsen 2013/06/28 10:19:11 I think you are right. Will try without.
+ } 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