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

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

Issue 289033002: Outputting command line if CreateProcess() fails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | no next file » | 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/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/metrics/histogram.h" 24 #include "base/metrics/histogram.h"
25 #include "base/process/kill.h" 25 #include "base/process/kill.h"
26 #include "base/strings/utf_string_conversions.h"
26 #include "base/sys_info.h" 27 #include "base/sys_info.h"
27 #include "base/win/object_watcher.h" 28 #include "base/win/object_watcher.h"
28 #include "base/win/scoped_handle.h" 29 #include "base/win/scoped_handle.h"
29 #include "base/win/scoped_process_information.h" 30 #include "base/win/scoped_process_information.h"
30 #include "base/win/startup_information.h" 31 #include "base/win/startup_information.h"
31 #include "base/win/windows_version.h" 32 #include "base/win/windows_version.h"
32 33
33 // userenv.dll is required for CreateEnvironmentBlock(). 34 // userenv.dll is required for CreateEnvironmentBlock().
34 #pragma comment(lib, "userenv.lib") 35 #pragma comment(lib, "userenv.lib")
35 36
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 187 }
187 188
188 BOOL launched = 189 BOOL launched =
189 CreateProcessAsUser(options.as_user, NULL, 190 CreateProcessAsUser(options.as_user, NULL,
190 const_cast<wchar_t*>(cmdline.c_str()), 191 const_cast<wchar_t*>(cmdline.c_str()),
191 NULL, NULL, inherit_handles, flags, 192 NULL, NULL, inherit_handles, flags,
192 enviroment_block, NULL, startup_info, 193 enviroment_block, NULL, startup_info,
193 &temp_process_info); 194 &temp_process_info);
194 DestroyEnvironmentBlock(enviroment_block); 195 DestroyEnvironmentBlock(enviroment_block);
195 if (!launched) { 196 if (!launched) {
196 DPLOG(ERROR); 197 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
198 << std::endl;;
197 return false; 199 return false;
198 } 200 }
199 } else { 201 } else {
200 if (!CreateProcess(NULL, 202 if (!CreateProcess(NULL,
201 const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, 203 const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL,
202 inherit_handles, flags, NULL, NULL, 204 inherit_handles, flags, NULL, NULL,
203 startup_info, &temp_process_info)) { 205 startup_info, &temp_process_info)) {
204 DPLOG(ERROR); 206 DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
207 << std::endl;;
205 return false; 208 return false;
206 } 209 }
207 } 210 }
208 base::win::ScopedProcessInformation process_info(temp_process_info); 211 base::win::ScopedProcessInformation process_info(temp_process_info);
209 212
210 if (options.job_handle) { 213 if (options.job_handle) {
211 if (0 == AssignProcessToJobObject(options.job_handle, 214 if (0 == AssignProcessToJobObject(options.job_handle,
212 process_info.process_handle())) { 215 process_info.process_handle())) {
213 DLOG(ERROR) << "Could not AssignProcessToObject."; 216 DLOG(ERROR) << "Could not AssignProcessToObject.";
214 KillProcess(process_info.process_handle(), kProcessKilledExitCode, true); 217 KillProcess(process_info.process_handle(), kProcessKilledExitCode, true);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 WaitForSingleObject(proc_info.process_handle(), INFINITE); 362 WaitForSingleObject(proc_info.process_handle(), INFINITE);
360 363
361 return true; 364 return true;
362 } 365 }
363 366
364 void RaiseProcessToHighPriority() { 367 void RaiseProcessToHighPriority() {
365 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 368 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
366 } 369 }
367 370
368 } // namespace base 371 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698