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

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

Issue 2083463003: Revert of Add chrome_crash_reporter_client_win.cc to the source file list for chrome_elf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « base/process/launch.h ('k') | base/strings/string_number_conversions.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>
11 #include <userenv.h> 11 #include <userenv.h>
12 #include <psapi.h> 12 #include <psapi.h>
13 13
14 #include <ios> 14 #include <ios>
15 #include <limits> 15 #include <limits>
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/bind_helpers.h" 18 #include "base/bind_helpers.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/debug/stack_trace.h" 20 #include "base/debug/stack_trace.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/process/kill.h" 24 #include "base/process/kill.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/sys_info.h" 26 #include "base/sys_info.h"
27 #include "base/win/object_watcher.h"
27 #include "base/win/scoped_handle.h" 28 #include "base/win/scoped_handle.h"
28 #include "base/win/scoped_process_information.h" 29 #include "base/win/scoped_process_information.h"
29 #include "base/win/startup_information.h" 30 #include "base/win/startup_information.h"
30 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
31 32
32 namespace base { 33 namespace base {
33 34
34 namespace { 35 namespace {
35 36
36 // This exit code is used by the Windows task manager when it kills a 37 // This exit code is used by the Windows task manager when it kills a
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // by this process. These IDs could have been reused by the time 140 // by this process. These IDs could have been reused by the time
140 // this function is called. The CRT checks the validity of 141 // this function is called. The CRT checks the validity of
141 // stdout/stderr on startup (before the handle IDs can be reused). 142 // stdout/stderr on startup (before the handle IDs can be reused).
142 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was 143 // _fileno(stdout) will return -2 (_NO_CONSOLE_FILENO) if stdout was
143 // invalid. 144 // invalid.
144 if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) { 145 if (_fileno(stdout) >= 0 || _fileno(stderr) >= 0) {
145 // _fileno was broken for SUBSYSTEM:WINDOWS from VS2010 to VS2012/2013. 146 // _fileno was broken for SUBSYSTEM:WINDOWS from VS2010 to VS2012/2013.
146 // http://crbug.com/358267. Confirm that the underlying HANDLE is valid 147 // http://crbug.com/358267. Confirm that the underlying HANDLE is valid
147 // before aborting. 148 // before aborting.
148 149
150 // This causes NaCl tests to hang on XP for reasons unclear, perhaps due
151 // to not being able to inherit handles. Since it's only for debugging,
152 // and redirecting still works, punt for now.
153 if (base::win::GetVersion() < base::win::VERSION_VISTA)
154 return;
155
149 intptr_t stdout_handle = _get_osfhandle(_fileno(stdout)); 156 intptr_t stdout_handle = _get_osfhandle(_fileno(stdout));
150 intptr_t stderr_handle = _get_osfhandle(_fileno(stderr)); 157 intptr_t stderr_handle = _get_osfhandle(_fileno(stderr));
151 if (stdout_handle >= 0 || stderr_handle >= 0) 158 if (stdout_handle >= 0 || stderr_handle >= 0)
152 return; 159 return;
153 } 160 }
154 161
155 if (!AttachConsole(ATTACH_PARENT_PROCESS)) { 162 if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
156 unsigned int result = GetLastError(); 163 unsigned int result = GetLastError();
157 // Was probably already attached. 164 // Was probably already attached.
158 if (result == ERROR_ACCESS_DENIED) 165 if (result == ERROR_ACCESS_DENIED)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 const LaunchOptions& options) { 210 const LaunchOptions& options) {
204 win::StartupInformation startup_info_wrapper; 211 win::StartupInformation startup_info_wrapper;
205 STARTUPINFO* startup_info = startup_info_wrapper.startup_info(); 212 STARTUPINFO* startup_info = startup_info_wrapper.startup_info();
206 213
207 bool inherit_handles = options.inherit_handles; 214 bool inherit_handles = options.inherit_handles;
208 DWORD flags = 0; 215 DWORD flags = 0;
209 if (options.handles_to_inherit) { 216 if (options.handles_to_inherit) {
210 if (options.handles_to_inherit->empty()) { 217 if (options.handles_to_inherit->empty()) {
211 inherit_handles = false; 218 inherit_handles = false;
212 } else { 219 } else {
220 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
221 DLOG(ERROR) << "Specifying handles to inherit requires Vista or later.";
222 return Process();
223 }
224
213 if (options.handles_to_inherit->size() > 225 if (options.handles_to_inherit->size() >
214 std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) { 226 std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) {
215 DLOG(ERROR) << "Too many handles to inherit."; 227 DLOG(ERROR) << "Too many handles to inherit.";
216 return Process(); 228 return Process();
217 } 229 }
218 230
219 // Ensure the handles can be inherited. 231 // Ensure the handles can be inherited.
220 for (HANDLE handle : *options.handles_to_inherit) { 232 for (HANDLE handle : *options.handles_to_inherit) {
221 BOOL result = SetHandleInformation(handle, HANDLE_FLAG_INHERIT, 233 BOOL result = SetHandleInformation(handle, HANDLE_FLAG_INHERIT,
222 HANDLE_FLAG_INHERIT); 234 HANDLE_FLAG_INHERIT);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 386
375 bool GetAppOutput(const StringPiece16& cl, std::string* output) { 387 bool GetAppOutput(const StringPiece16& cl, std::string* output) {
376 return GetAppOutputInternal(cl, false, output); 388 return GetAppOutputInternal(cl, false, output);
377 } 389 }
378 390
379 void RaiseProcessToHighPriority() { 391 void RaiseProcessToHighPriority() {
380 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 392 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
381 } 393 }
382 394
383 } // namespace base 395 } // namespace base
OLDNEW
« no previous file with comments | « base/process/launch.h ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698