From: Greg Ames Date: Fri, 10 Aug 2001 01:34:11 +0000 (+0000) Subject: record something in the error log if the parent process seg faults X-Git-Tag: 2.0.24~133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c8e8e399018b5a91fb031b2eba4c38dcd785535;p=apache record something in the error log if the parent process seg faults Submitted by: Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90064 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index e665d86673..fda1f03601 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -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); diff --git a/server/mpm/threaded/threaded.c b/server/mpm/threaded/threaded.c index f0b8992673..50bfc5d596 100644 --- a/server/mpm/threaded/threaded.c +++ b/server/mpm/threaded/threaded.c @@ -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); diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 3d1b8736c1..6f4f539044 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -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);