#include "base/process/kill.h"
#include "base/functional/bind.h"
#include "base/process/process_iterator.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "build/build_config.h"
namespace base {
bool KillProcesses(const FilePath::StringType& executable_name,
int exit_code,
const ProcessFilter* filter) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_FUCHSIA)
void EnsureProcessTerminated(Process process) {
DCHECK(!process.is_current());
if (process.WaitForExitWithTimeout(TimeDelta(), nullptr))
return;
ThreadPool::PostDelayedTask(
FROM_HERE,
{TaskPriority::BEST_EFFORT, TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
BindOnce(
[](Process process) {
if (process.WaitForExitWithTimeout(TimeDelta(), nullptr))
return;
#if BUILDFLAG(IS_WIN)
process.Terminate(win::kProcessKilledExitCode, false);
#else
process.Terminate(-1, false);
#endif
},
std::move(process)),
Seconds(2));
}
#endif
}