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

Side by Side Diff: runtime/bin/file_win.cc

Issue 854633005: Fix incorrect handling of closing stderr on Windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | tests/standalone/standalone.status » ('j') | no next file with comments »
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_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 27 matching lines...) Expand all
38 38
39 39
40 File::~File() { 40 File::~File() {
41 Close(); 41 Close();
42 delete handle_; 42 delete handle_;
43 } 43 }
44 44
45 45
46 void File::Close() { 46 void File::Close() {
47 ASSERT(handle_->fd() >= 0); 47 ASSERT(handle_->fd() >= 0);
48 if (handle_->fd() == _fileno(stdout)) { 48 if (handle_->fd() == _fileno(stdout) || handle_->fd() == _fileno(stderr)) {
49 int fd = _open("NUL", _O_WRONLY); 49 int fd = _open("NUL", _O_WRONLY);
50 ASSERT(fd >= 0); 50 ASSERT(fd >= 0);
51 _dup2(fd, handle_->fd()); 51 _dup2(fd, handle_->fd());
52 close(fd); 52 close(fd);
53 } else { 53 } else {
54 int err = close(handle_->fd()); 54 int err = close(handle_->fd());
55 if (err != 0) { 55 if (err != 0) {
56 Log::PrintErr("%s\n", strerror(errno)); 56 Log::PrintErr("%s\n", strerror(errno));
57 } 57 }
58 } 58 }
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 return kIdentical; 684 return kIdentical;
685 } else { 685 } else {
686 return kDifferent; 686 return kDifferent;
687 } 687 }
688 } 688 }
689 689
690 } // namespace bin 690 } // namespace bin
691 } // namespace dart 691 } // namespace dart
692 692
693 #endif // defined(TARGET_OS_WINDOWS) 693 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698