]> granicus.if.org Git - apache/commitdiff
record something in the error log if the parent process seg faults
authorGreg Ames <gregames@apache.org>
Fri, 10 Aug 2001 01:34:11 +0000 (01:34 +0000)
committerGreg Ames <gregames@apache.org>
Fri, 10 Aug 2001 01:34:11 +0000 (01:34 +0000)
Submitted by: Jeff Trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90064 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/prefork/prefork.c
server/mpm/threaded/threaded.c
server/mpm/worker/worker.c

index e665d8667354d7eb8eb3375f95914bb183c3730a..fda1f03601cb0b7c356493917bb8b67e5e0b1107 100644 (file)
@@ -179,6 +179,7 @@ static apr_pool_t *pconf;           /* Pool for config stuff */
 static apr_pool_t *pchild;             /* Pool for httpd child stuff */
 
 static pid_t ap_my_pid;        /* it seems silly to call getpid all the time */
+static pid_t parent_pid;
 #ifndef MULTITHREAD
 static int my_child_num;
 #endif
@@ -383,6 +384,12 @@ static void sig_coredump(int sig)
 {
     chdir(ap_coredump_dir);
     apr_signal(sig, SIG_DFL);
+    if (ap_my_pid == parent_pid) {
+            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                         0, ap_server_conf,
+                         "seg fault or similar nasty error detected "
+                         "in the parent process");
+    }
     kill(getpid(), sig);
     /* At this point we've got sig blocked, because we're still inside
      * the signal handler.  When we leave the signal handler it will
@@ -1314,7 +1321,7 @@ static void prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem
            apr_proc_detach();
        }
 
-       ap_my_pid = getpid();
+       parent_pid = ap_my_pid = getpid();
     }
 
     unixd_pre_config(ptemp);
index f0b8992673c812bfa93b3d12f4f652b965a55fd3..50bfc5d596352327e707238c9f9352a4957b6840 100644 (file)
@@ -174,6 +174,7 @@ static apr_pool_t *pchild;          /* Pool for httpd child stuff */
 
 static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main 
                            thread. Use this instead */
+static pid_t parent_pid;
 /* Keep track of the number of worker threads currently active */
 static int worker_thread_count;
 static apr_lock_t *worker_thread_count_mutex;
@@ -247,6 +248,18 @@ static void sig_coredump(int sig)
 {
     chdir(ap_coredump_dir);
     apr_signal(sig, SIG_DFL);
+    if (ap_my_pid == parent_pid) {
+        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                     0, ap_server_conf,
+                     "seg fault or similar nasty error detected "
+                     "in the parent process");
+        
+        /* XXX we can probably add some rudimentary cleanup code here,
+         * like getting rid of the pid file.  If any additional bad stuff
+         * happens, we are protected from recursive errors taking down the
+         * system since this function is no longer the signal handler   GLA
+         */
+    }
     kill(ap_my_pid, sig);
     /* At this point we've got sig blocked, because we're still inside
      * the signal handler.  When we leave the signal handler it will
@@ -1348,7 +1361,7 @@ static void threaded_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t
        if (!one_process && !no_detach) {
            apr_proc_detach();
        }
-       ap_my_pid = getpid();
+       parent_pid = ap_my_pid = getpid();
     }
 
     unixd_pre_config(ptemp);
index 3d1b8736c17a9c2d25ae2b8efeb9072e02fbfc31..6f4f539044bfeb737c3b5b89782c201f11edee97 100644 (file)
@@ -183,6 +183,7 @@ static apr_pool_t *pchild;          /* Pool for httpd child stuff */
 
 static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main 
                            thread. Use this instead */
+static pid_t parent_pid;
 /* Keep track of the number of worker threads currently active */
 static int worker_thread_count;
 static apr_lock_t *worker_thread_count_mutex;
@@ -262,6 +263,18 @@ static void sig_coredump(int sig)
 {
     chdir(ap_coredump_dir);
     apr_signal(sig, SIG_DFL);
+    if (ap_my_pid == parent_pid) {
+        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                     0, ap_server_conf,
+                     "seg fault or similar nasty error detected "
+                     "in the parent process");
+        
+        /* XXX we can probably add some rudimentary cleanup code here,
+         * like getting rid of the pid file.  If any additional bad stuff
+         * happens, we are protected from recursive errors taking down the
+         * system since this function is no longer the signal handler   GLA
+         */
+    }
     kill(ap_my_pid, sig);
     /* At this point we've got sig blocked, because we're still inside
      * the signal handler.  When we leave the signal handler it will
@@ -1403,7 +1416,7 @@ static void worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *p
        if (!one_process && !no_detach) {
            apr_proc_detach();
        }
-       ap_my_pid = getpid();
+       parent_pid = ap_my_pid = getpid();
     }
 
     unixd_pre_config(ptemp);