Commit b63f00de authored by Wez's avatar Wez Committed by Commit Bot

Fix chrome://kill debug URL to simulate process kills correctly.

The implementation of this debug URL was changed in
https://chromium-review.googlesource.com/c/chromium/src/+/907675 to one
which _exit()s the process under POSIX, rather than self-terminating via
kill().  Since we detect process kills (versus self-termination, crashes
etc) by checking for SIGTERM, this broke chrome://kill.

Fix chrome://kill by explicitly kill()ing the process, and structure the
implementation to make clear that we need to simulate termination by a
peer process, specifically.

Bug: 806451, 854926
Change-Id: I0408dd1d248e04b3045f37d46051c220b33ab081
Reviewed-on: https://chromium-review.googlesource.com/1116076Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570801}
parent 9c76065c
...@@ -234,6 +234,12 @@ ...@@ -234,6 +234,12 @@
#include "content/renderer/pepper/plugin_module.h" #include "content/renderer/pepper/plugin_module.h"
#endif #endif
#if defined(OS_WIN)
#include "base/process/kill.h"
#elif defined(OS_POSIX)
#include <signal.h>
#endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include <cpu-features.h> #include <cpu-features.h>
...@@ -891,11 +897,20 @@ void HandleChromeDebugURL(const GURL& url) { ...@@ -891,11 +897,20 @@ void HandleChromeDebugURL(const GURL& url) {
// base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation
// of base::debug::DumpWithoutCrashing for more details. // of base::debug::DumpWithoutCrashing for more details.
base::debug::DumpWithoutCrashing(); base::debug::DumpWithoutCrashing();
#if defined(OS_WIN) || defined(OS_POSIX)
} else if (url == kChromeUIKillURL) { } else if (url == kChromeUIKillURL) {
LOG(ERROR) << "Intentionally terminating current process because user" LOG(ERROR) << "Intentionally terminating current process because user"
" navigated to " " navigated to "
<< url.spec(); << url.spec();
base::Process::TerminateCurrentProcessImmediately(1); // Simulate termination such that the base::GetTerminationStatus() API will
// return TERMINATION_STATUS_PROCESS_WAS_KILLED.
#if defined(OS_WIN)
base::Process::TerminateCurrentProcessImmediately(
base::win::kProcessKilledExitCode);
#elif defined(OS_POSIX)
PCHECK(kill(base::Process::Current().Pid(), SIGTERM) == 0);
#endif
#endif // defined(OS_WIN) || defined(OS_POSIX)
} else if (url == kChromeUIHangURL) { } else if (url == kChromeUIHangURL) {
LOG(ERROR) << "Intentionally hanging ourselves with sleep infinite loop" LOG(ERROR) << "Intentionally hanging ourselves with sleep infinite loop"
<< " because user navigated to " << url.spec(); << " because user navigated to " << url.spec();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment