Commit 93ae8193 authored by byungchul's avatar byungchul Committed by Commit bot

Get SIGTERM when parent process dies.

Cast shell needs to exist when the parent process dies.

BUG=internal b/19182288

Review URL: https://codereview.chromium.org/872073005

Cr-Commit-Position: refs/heads/master@{#315356}
parent befec2df
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chromecast/browser/cast_browser_main_parts.h" #include "chromecast/browser/cast_browser_main_parts.h"
#include <signal.h> #include <signal.h>
#include <sys/prctl.h>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
...@@ -57,6 +58,8 @@ void RunClosureOnSignal(int signum) { ...@@ -57,6 +58,8 @@ void RunClosureOnSignal(int signum) {
void RegisterClosureOnSignal(const base::Closure& closure) { void RegisterClosureOnSignal(const base::Closure& closure) {
DCHECK(!g_signal_closure); DCHECK(!g_signal_closure);
DCHECK_GT(arraysize(kSignalsToRunClosure), 0U);
// Allow memory leak by intention. // Allow memory leak by intention.
g_signal_closure = new base::Closure(closure); g_signal_closure = new base::Closure(closure);
...@@ -74,6 +77,9 @@ void RegisterClosureOnSignal(const base::Closure& closure) { ...@@ -74,6 +77,9 @@ void RegisterClosureOnSignal(const base::Closure& closure) {
DCHECK_EQ(sa_old.sa_handler, SIG_DFL); DCHECK_EQ(sa_old.sa_handler, SIG_DFL);
} }
} }
// Get the first signal to exit when the parent process dies.
prctl(PR_SET_PDEATHSIG, kSignalsToRunClosure[0]);
} }
} // namespace } // namespace
......
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