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

Side by Side Diff: base/process_util_win.cc

Issue 8667006: Extract similar code into SetJobObjectAsKillOnJobClose() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « base/process_util.h ('k') | chrome/common/chrome_content_client.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 return true; 299 return true;
300 } 300 }
301 301
302 bool LaunchProcess(const CommandLine& cmdline, 302 bool LaunchProcess(const CommandLine& cmdline,
303 const LaunchOptions& options, 303 const LaunchOptions& options,
304 ProcessHandle* process_handle) { 304 ProcessHandle* process_handle) {
305 return LaunchProcess(cmdline.GetCommandLineString(), options, process_handle); 305 return LaunchProcess(cmdline.GetCommandLineString(), options, process_handle);
306 } 306 }
307 307
308 bool SetJobObjectAsKillOnJobClose(HANDLE job_object) {
309 JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {0};
310 limit_info.BasicLimitInformation.LimitFlags =
311 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
312 if (0 == SetInformationJobObject(job_object,
M-A Ruel 2011/11/23 03:01:40 style nit: (optional) return 0 != SetInformationJ
Takashi Toyoshima 2011/11/23 04:36:55 Done.
313 JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info)))
314 return false;
315 return true;
316 }
317
308 // Attempts to kill the process identified by the given process 318 // Attempts to kill the process identified by the given process
309 // entry structure, giving it the specified exit code. 319 // entry structure, giving it the specified exit code.
310 // Returns true if this is successful, false otherwise. 320 // Returns true if this is successful, false otherwise.
311 bool KillProcessById(ProcessId process_id, int exit_code, bool wait) { 321 bool KillProcessById(ProcessId process_id, int exit_code, bool wait) {
312 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 322 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE,
313 FALSE, // Don't inherit handle 323 FALSE, // Don't inherit handle
314 process_id); 324 process_id);
315 if (!process) { 325 if (!process) {
316 DLOG(ERROR) << "Unable to open process " << process_id << " : " 326 DLOG(ERROR) << "Unable to open process " << process_id << " : "
317 << GetLastError(); 327 << GetLastError();
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 912
903 PERFORMANCE_INFORMATION info; 913 PERFORMANCE_INFORMATION info;
904 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { 914 if (!InternalGetPerformanceInfo(&info, sizeof(info))) {
905 DLOG(ERROR) << "Failed to fetch internal performance info."; 915 DLOG(ERROR) << "Failed to fetch internal performance info.";
906 return 0; 916 return 0;
907 } 917 }
908 return (info.CommitTotal * system_info.dwPageSize) / 1024; 918 return (info.CommitTotal * system_info.dwPageSize) / 1024;
909 } 919 }
910 920
911 } // namespace base 921 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698