Reviewers: danno,

Message:
This is my first time sending a patch to V8. I'm probably doing something silly,
so please let me know what I'm doing wrong :)

Description:
Pass the SIGPROF signal on to previously registered signal handler.

This enables the google-perftools SIGPROF signal handler to continue to work
properly.

BUG=none


Please review this at https://codereview.chromium.org/11195045/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/platform-linux.cc


Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index beb2ccee297fa062a8951fee7098a9f9b91a2de3..d3034a12dabec86f9a3c8c3342f50851f7da3536 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -77,6 +77,7 @@ namespace internal {
 // name space and pid 0 is reserved (see man 2 kill).
 static const pthread_t kNoThread = (pthread_t) 0;

+static void (*g_old_signal_handler)(int, siginfo_t *, void *) = NULL;

 double ceiling(double x) {
   return ceil(x);
@@ -1020,6 +1021,7 @@ static int GetThreadID() {
static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
   USE(info);
   if (signal != SIGPROF) return;
+  if (g_old_signal_handler) g_old_signal_handler(signal, info, context);
   Isolate* isolate = Isolate::UncheckedCurrent();
if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) {
     // We require a fully initialized and entered isolate.
@@ -1108,11 +1110,14 @@ class SignalSender : public Thread {
     sa.sa_flags = SA_RESTART | SA_SIGINFO;
     signal_handler_installed_ =
         (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
+    if (signal_handler_installed_)
+      g_old_signal_handler = old_signal_handler_.sa_sigaction;
   }

   static void RestoreSignalHandler() {
     if (signal_handler_installed_) {
       sigaction(SIGPROF, &old_signal_handler_, 0);
+      g_old_signal_handler = NULL;
       signal_handler_installed_ = false;
     }
   }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to