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

Side by Side Diff: base/process/launch_win.cc

Issue 2810903002: Revert of Allow handles through for official builds too (partial revert) (patchset #3 id:40001 of h… (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | content/common/sandbox_win.cc » ('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 Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process/launch.h" 5 #include "base/process/launch.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <windows.h> 10 #include <windows.h>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // likely does not go anywhere. 135 // likely does not go anywhere.
136 // 136 //
137 // We don't use GetStdHandle() to check stdout/stderr here because 137 // We don't use GetStdHandle() to check stdout/stderr here because
138 // it can return dangling IDs of handles that were never inherited 138 // it can return dangling IDs of handles that were never inherited
139 // by this process. These IDs could have been reused by the time 139 // by this process. These IDs could have been reused by the time
140 // this function is called. The CRT checks the validity of 140 // this function is called. The CRT checks the validity of
141 // stdout/stderr on startup (before the handle IDs can be reused). 141 // stdout/stderr on startup (before the handle IDs can be reused).
142 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was 142 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was
143 // invalid. 143 // invalid.
144 if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) { 144 if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) {
145 return; 145 // _fileno was broken for SUBSYSTEM:WINDOWS from VS2010 to VS2012/2013.
146 // http://crbug.com/358267. Confirm that the underlying HANDLE is valid
147 // before aborting.
148
149 intptr_t stdout_handle = _get_osfhandle(_fileno(stdout));
150 intptr_t stderr_handle = _get_osfhandle(_fileno(stderr));
151 if (stdout_handle >= 0 || stderr_handle >= 0)
152 return;
146 } 153 }
147 154
148 if (!AttachConsole(ATTACH_PARENT_PROCESS)) { 155 if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
149 unsigned int result = GetLastError(); 156 unsigned int result = GetLastError();
150 // Was probably already attached. 157 // Was probably already attached.
151 if (result == ERROR_ACCESS_DENIED) 158 if (result == ERROR_ACCESS_DENIED)
152 return; 159 return;
153 // Don't bother creating a new console for each child process if the 160 // Don't bother creating a new console for each child process if the
154 // parent process is invalid (eg: crashed). 161 // parent process is invalid (eg: crashed).
155 if (result == ERROR_GEN_FAILURE) 162 if (result == ERROR_GEN_FAILURE)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 374
368 bool GetAppOutput(const StringPiece16& cl, std::string* output) { 375 bool GetAppOutput(const StringPiece16& cl, std::string* output) {
369 return GetAppOutputInternal(cl, false, output); 376 return GetAppOutputInternal(cl, false, output);
370 } 377 }
371 378
372 void RaiseProcessToHighPriority() { 379 void RaiseProcessToHighPriority() {
373 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 380 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
374 } 381 }
375 382
376 } // namespace base 383 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | content/common/sandbox_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698