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

Unified Diff: content/renderer/renderer_main.cc

Issue 9837053: Added code for renderer to cleanly exit. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: git try Created 8 years, 9 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: content/renderer/renderer_main.cc
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc
index 306dee9aaf0ea6a511c53ae66884e431dc7abb29..6d8d2001871a7a3ccc4308a2a0d976f48c1fa577 100644
--- a/content/renderer/renderer_main.cc
+++ b/content/renderer/renderer_main.cc
@@ -126,6 +126,25 @@ class RendererMessageLoopObserver : public MessageLoop::TaskObserver {
DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver);
};
+#if defined(RENDERER_SIGTERM_HANDLER)
+static void SigtermHandler(int signum)
+{
Evan Martin 2012/03/26 17:17:25 curly should be on same line of function decl (see
+ LOG(INFO) << "SIGTERM caught by the renderer process. Calling exit().";
Evan Martin 2012/03/26 17:17:25 I think LOG() probably does a bunch of stuff that
+ exit(signum);
+}
+
+static void AddSigtermHandler()
+{
+ struct sigaction termAction;
Evan Martin 2012/03/26 17:17:25 variable names should be like term_action
+ termAction.sa_handler = SigtermHandler;
+ sigfillset(&termAction.sa_mask);
+ termAction.sa_flags = 0;
+ LOG(INFO) << "Installing SIGTERM handler to the renderer process.";
+ sigaction(SIGTERM, &termAction, NULL);
+ LOG(INFO) << "Added SIGTERM handler to the renderer process.";
Evan Martin 2012/03/26 17:17:25 Rather than this, perhaps you should just check th
+}
+#endif
+
// mainline routine for running as the Renderer process
int RendererMain(const content::MainFunctionParams& parameters) {
TRACE_EVENT_BEGIN_ETW("RendererMain", 0, "");
@@ -232,6 +251,10 @@ int RendererMain(const content::MainFunctionParams& parameters) {
startup_timer.Stop(); // End of Startup Time Measurement.
+#if defined(RENDERER_SIGTERM_HANDLER)
+ AddSigtermHandler();
+#endif
+
if (run_loop) {
#if defined(OS_MACOSX)
if (pool)
« 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