Chromium Code Reviews| Index: base/process_util_win.cc |
| =================================================================== |
| --- base/process_util_win.cc (revision 99780) |
| +++ base/process_util_win.cc (working copy) |
| @@ -237,8 +237,19 @@ |
| startup_info.wShowWindow = options.start_hidden ? SW_HIDE : SW_SHOW; |
| PROCESS_INFORMATION process_info; |
| + DWORD flags = 0; |
| + |
| + if (options.job_handle) { |
| + flags |= CREATE_SUSPENDED; |
| + |
| + // If this code is run under a debugger, the launched process is |
| + // automatically associated with a job object created by the debugger. |
| + // The CREATE_BREAKAWAY_FROM_JOB flag is used to prevent this. |
| + flags |= CREATE_BREAKAWAY_FROM_JOB; |
| + } |
| + |
| if (options.as_user) { |
| - DWORD flags = CREATE_UNICODE_ENVIRONMENT; |
| + flags |= CREATE_UNICODE_ENVIRONMENT; |
| void* enviroment_block = NULL; |
| if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) |
| @@ -256,12 +267,23 @@ |
| } else { |
| if (!CreateProcess(NULL, |
| const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, |
| - options.inherit_handles, 0, NULL, NULL, |
| + options.inherit_handles, flags, NULL, NULL, |
| &startup_info, &process_info)) { |
| return false; |
| } |
| } |
| + if (options.job_handle) { |
| + if (0 == AssignProcessToJobObject(options.job_handle, |
| + process_info.hProcess)) { |
| + LOG(ERROR) << "Could not AssignProcessToObject."; |
| + KillProcess(process_info.hProcess, 1, true); |
|
cpu_(ooo_6.6-7.5)
2011/09/07 21:09:49
use kProcessKilledExitCode
Paweł Hajdan Jr.
2011/09/07 21:54:58
Done.
|
| + return false; |
| + } |
| + |
| + ResumeThread(process_info.hThread); |
| + } |
| + |
| // Handles must be closed or they will leak. |
| CloseHandle(process_info.hThread); |