Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_util.h" | 5 #include "base/process_util.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include <userenv.h> | 10 #include <userenv.h> |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 bool LaunchProcess(const string16& cmdline, | 286 bool LaunchProcess(const string16& cmdline, |
| 287 const LaunchOptions& options, | 287 const LaunchOptions& options, |
| 288 ProcessHandle* process_handle) { | 288 ProcessHandle* process_handle) { |
| 289 STARTUPINFO startup_info = {}; | 289 STARTUPINFO startup_info = {}; |
| 290 startup_info.cb = sizeof(startup_info); | 290 startup_info.cb = sizeof(startup_info); |
| 291 if (options.empty_desktop_name) | 291 if (options.empty_desktop_name) |
| 292 startup_info.lpDesktop = L""; | 292 startup_info.lpDesktop = L""; |
| 293 startup_info.dwFlags = STARTF_USESHOWWINDOW; | 293 startup_info.dwFlags = STARTF_USESHOWWINDOW; |
| 294 startup_info.wShowWindow = options.start_hidden ? SW_HIDE : SW_SHOW; | 294 startup_info.wShowWindow = options.start_hidden ? SW_HIDE : SW_SHOW; |
| 295 | 295 |
| 296 if (options.stdin_handle || options.stdout_handle || options.stderr_handle) { | |
| 297 startup_info.dwFlags |= STARTF_USESTDHANDLES; | |
| 298 startup_info.hStdInput = options.stdin_handle ? | |
| 299 options.stdin_handle : GetStdHandle(STD_INPUT_HANDLE); | |
|
rvargas (doing something else)
2012/12/01 01:40:45
What happens when the current process has a non-de
Sergey Ulanov
2012/12/05 00:23:15
Isn't this the default behavior, i.e. aren't stdin
rvargas (doing something else)
2012/12/05 21:51:36
Sorry, I don't really follow this. What do you mea
Sergey Ulanov
2012/12/05 22:38:53
I didn't know about it. Is it documented anywhere
rvargas (doing something else)
2012/12/06 00:52:16
If the default behavior were to inherit handles th
Sergey Ulanov
2012/12/07 23:11:56
What I was asking about is if there is a way to re
rvargas (doing something else)
2012/12/07 23:46:52
I suspect passing INVALID_HANDLE_VALUE has that ef
| |
| 300 startup_info.hStdOutput = options.stdout_handle ? | |
| 301 options.stdout_handle : GetStdHandle(STD_OUTPUT_HANDLE); | |
| 302 startup_info.hStdError = options.stderr_handle ? | |
| 303 options.stderr_handle : GetStdHandle(STD_ERROR_HANDLE); | |
| 304 } | |
| 305 | |
| 296 DWORD flags = 0; | 306 DWORD flags = 0; |
| 297 | 307 |
| 298 if (options.job_handle) { | 308 if (options.job_handle) { |
| 299 flags |= CREATE_SUSPENDED; | 309 flags |= CREATE_SUSPENDED; |
| 300 | 310 |
| 301 // If this code is run under a debugger, the launched process is | 311 // If this code is run under a debugger, the launched process is |
| 302 // automatically associated with a job object created by the debugger. | 312 // automatically associated with a job object created by the debugger. |
| 303 // The CREATE_BREAKAWAY_FROM_JOB flag is used to prevent this. | 313 // The CREATE_BREAKAWAY_FROM_JOB flag is used to prevent this. |
| 304 flags |= CREATE_BREAKAWAY_FROM_JOB; | 314 flags |= CREATE_BREAKAWAY_FROM_JOB; |
| 305 } | 315 } |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 | 983 |
| 974 PERFORMANCE_INFORMATION info; | 984 PERFORMANCE_INFORMATION info; |
| 975 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 985 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
| 976 DLOG(ERROR) << "Failed to fetch internal performance info."; | 986 DLOG(ERROR) << "Failed to fetch internal performance info."; |
| 977 return 0; | 987 return 0; |
| 978 } | 988 } |
| 979 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 989 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
| 980 } | 990 } |
| 981 | 991 |
| 982 } // namespace base | 992 } // namespace base |
| OLD | NEW |