Index: content/renderer/renderer_main.cc |
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc |
index 306dee9aaf0ea6a511c53ae66884e431dc7abb29..c6e99e3cbb3060bb2e0c8be57b800e783aa07d2e 100644 |
--- a/content/renderer/renderer_main.cc |
+++ b/content/renderer/renderer_main.cc |
@@ -126,6 +126,31 @@ class RendererMessageLoopObserver : public MessageLoop::TaskObserver { |
DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); |
}; |
+#if defined(RENDERER_CLEAN_EXIT) |
+static void SigtermHandler(int signal_number) |
+{ |
+ fprintf(stderr, "SIGTERM caught by the renderer process.\n"); |
+ fprintf(stderr, "Calling clean_exit().\n"); |
Markus (顧孟勤)
2012/03/28 23:07:56
You cannot call fprintf() from a signal handler.
asharif1
2012/03/29 02:13:11
Done.
|
+ base::clean_exit(signal_number); |
+} |
+ |
+static void AddSigtermHandler() |
+{ |
+ struct sigaction term_action; |
Markus (顧孟勤)
2012/03/28 23:07:56
It is good practice to use memset() to clear out a
asharif1
2012/03/29 02:13:11
Done.
|
+ int return_value; |
+ term_action.sa_handler = SigtermHandler; |
+ sigfillset(&term_action.sa_mask); |
+ term_action.sa_flags = 0; |
+ fprintf(stderr, "Installing SIGTERM handler to the renderer process.\n"); |
Markus (顧孟勤)
2012/03/28 23:07:56
Why do you need to print this message? We typicall
asharif1
2012/03/29 02:13:11
Done.
|
+ return_value = sigaction(SIGTERM, &term_action, NULL); |
Markus (顧孟勤)
2012/03/28 23:07:56
If sigaction() failed, you should trigger a CHECK(
asharif1
2012/03/29 02:13:11
Done.
|
+ if (!return_value) |
+ fprintf(stderr, "Installed SIGTERM handler to the renderer process.\n"); |
+ else |
+ fprintf(stderr, |
+ "Couldn't install SIGTERM handler to the renderer process.\n"); |
+} |
+#endif // defined(RENDERER_CLEAN_EXIT) |
+ |
// mainline routine for running as the Renderer process |
int RendererMain(const content::MainFunctionParams& parameters) { |
TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); |
@@ -232,6 +257,10 @@ int RendererMain(const content::MainFunctionParams& parameters) { |
startup_timer.Stop(); // End of Startup Time Measurement. |
+#if defined(RENDERER_CLEAN_EXIT) |
+ AddSigtermHandler(); |
Markus (顧孟勤)
2012/03/28 23:07:56
Can you say a little more about the rationale for
asharif1
2012/03/29 02:13:11
Read the CL description.
My goal is to run exit h
|
+#endif |
+ |
if (run_loop) { |
#if defined(OS_MACOSX) |
if (pool) |