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

Unified Diff: chrome/browser/component_updater/component_patcher_win.cc

Issue 17314017: the patcher process runs inside of a job (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/component_patcher_win.cc
diff --git a/chrome/browser/component_updater/component_patcher_win.cc b/chrome/browser/component_updater/component_patcher_win.cc
index 97aaeeefcccbe5020217a8f514f8dbf9e580dd24..6d6a63681f53be7b078defc180d59d728a1611d0 100644
--- a/chrome/browser/component_updater/component_patcher_win.cc
+++ b/chrome/browser/component_updater/component_patcher_win.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,6 +12,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_util.h"
+#include "base/win/scoped_handle.h"
#include "chrome/installer/util/util_constants.h"
namespace {
@@ -79,17 +80,30 @@ ComponentUnpacker::Error ComponentPatcherWin::Patch(
cl.AppendSwitchPath(installer::switches::kPatchFile, patch_file);
cl.AppendSwitchPath(installer::switches::kOutputFile, output_file);
+ // Create the child process in a job object. The job object prevents leaving
+ // child processes around when the parent process exits, either gracefully or
+ // accidentally.
+ base::win::ScopedHandle job(CreateJobObject(NULL, NULL));
+ if (!job || !base::SetJobObjectAsKillOnJobClose(job)) {
+ *error = GetLastError();
+ return ComponentUnpacker::kDeltaPatchProcessFailure;
+ }
+
base::LaunchOptions launch_options;
launch_options.wait = true;
+ launch_options.job_handle = job;
launch_options.start_hidden = true;
CommandLine setup_path(exe_path);
setup_path.AppendArguments(cl, false);
- base::ProcessHandle ph;
+ // |ph| is closed by WaitForExitCode.
+ base::ProcessHandle ph = base::kNullProcessHandle;
int exit_code = 0;
if (!base::LaunchProcess(setup_path, launch_options, &ph) ||
- !base::WaitForExitCode(ph, &exit_code))
+ !base::WaitForExitCode(ph, &exit_code)) {
+ *error = GetLastError();
return ComponentUnpacker::kDeltaPatchProcessFailure;
+ }
*error = exit_code;
return *error ? ComponentUnpacker::kDeltaOperationFailure :
« 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