You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2003/04/09 18:58:33 UTC
cvs commit: httpd-2.0/server/mpm/worker mpm.h worker.c
trawick 2003/04/09 09:58:31
Modified: include mpm_common.h
server mpm_common.c
server/mpm/experimental/leader leader.c mpm.h
server/mpm/experimental/perchild mpm.h perchild.c
server/mpm/experimental/threadpool mpm.h threadpool.c
server/mpm/prefork mpm.h prefork.c
server/mpm/worker mpm.h worker.c
Log:
consolidate code related to sig_coredump
a note on perchild:
perchild exception handling was busted before this and is still busted
the problem I noticed was that a client that exposes a segfault never
gets its connection dropped and the parent never notices that the
child process that segfaulted hasexited
Revision Changes Path
1.42 +5 -0 httpd-2.0/include/mpm_common.h
Index: mpm_common.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/mpm_common.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- mpm_common.h 6 Mar 2003 21:48:58 -0000 1.41
+++ mpm_common.h 9 Apr 2003 16:58:28 -0000 1.42
@@ -292,6 +292,11 @@
const char *arg);
#endif
+#ifdef AP_MPM_WANT_FATAL_SIGNAL_HANDLER
+extern apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *pconf);
+extern apr_status_t ap_fatal_signal_child_setup(server_rec *s);
+#endif
+
#ifdef __cplusplus
}
#endif
1.106 +101 -0 httpd-2.0/server/mpm_common.c
Index: mpm_common.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- mpm_common.c 20 Mar 2003 21:50:40 -0000 1.105
+++ mpm_common.c 9 Apr 2003 16:58:29 -0000 1.106
@@ -97,6 +97,9 @@
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
+#if APR_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
void ap_reclaim_child_processes(int terminate)
@@ -910,3 +913,101 @@
}
#endif /* AP_MPM_WANT_SET_MAX_MEM_FREE */
+
+#ifdef AP_MPM_WANT_FATAL_SIGNAL_HANDLER
+
+static pid_t parent_pid, my_pid;
+apr_pool_t *pconf;
+
+/* handle all varieties of core dumping signals */
+static void sig_coredump(int sig)
+{
+ apr_filepath_set(ap_coredump_dir, pconf);
+ apr_signal(sig, SIG_DFL);
+ if (my_pid == parent_pid) {
+ ap_log_error(APLOG_MARK, 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(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
+ * be unblocked, and we'll take the signal... and coredump or whatever
+ * is appropriate for this particular Unix. In addition the parent
+ * will see the real signal we received -- whereas if we called
+ * abort() here, the parent would only see SIGABRT.
+ */
+}
+
+apr_status_t ap_fatal_signal_child_setup(server_rec *s)
+{
+ my_pid = getpid();
+ return APR_SUCCESS;
+}
+
+apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *in_pconf)
+{
+#ifndef NO_USE_SIGACTION
+ struct sigaction sa;
+
+ sigemptyset(&sa.sa_mask);
+
+#if defined(SA_ONESHOT)
+ sa.sa_flags = SA_ONESHOT;
+#elif defined(SA_RESETHAND)
+ sa.sa_flags = SA_RESETHAND;
+#else
+ sa.sa_flags = 0;
+#endif
+
+ sa.sa_handler = sig_coredump;
+ if (sigaction(SIGSEGV, &sa, NULL) < 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGSEGV)");
+#ifdef SIGBUS
+ if (sigaction(SIGBUS, &sa, NULL) < 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGBUS)");
+#endif
+#ifdef SIGABORT
+ if (sigaction(SIGABORT, &sa, NULL) < 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGABORT)");
+#endif
+#ifdef SIGABRT
+ if (sigaction(SIGABRT, &sa, NULL) < 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGABRT)");
+#endif
+#ifdef SIGILL
+ if (sigaction(SIGILL, &sa, NULL) < 0)
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, s, "sigaction(SIGILL)");
+#endif
+
+#else /* NO_USE_SIGACTION */
+
+ apr_signal(SIGSEGV, sig_coredump);
+#ifdef SIGBUS
+ apr_signal(SIGBUS, sig_coredump);
+#endif /* SIGBUS */
+#ifdef SIGABORT
+ apr_signal(SIGABORT, sig_coredump);
+#endif /* SIGABORT */
+#ifdef SIGABRT
+ apr_signal(SIGABRT, sig_coredump);
+#endif /* SIGABRT */
+#ifdef SIGILL
+ apr_signal(SIGILL, sig_coredump);
+#endif /* SIGILL */
+
+#endif /* NO_USE_SIGACTION */
+
+ pconf = in_pconf;
+ parent_pid = my_pid = getpid();
+
+ return APR_SUCCESS;
+}
+
+#endif /* AP_MPM_WANT_FATAL_SIGNAL_HANDLER */
1.28 +7 -72 httpd-2.0/server/mpm/experimental/leader/leader.c
Index: leader.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/leader/leader.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- leader.c 3 Feb 2003 17:53:22 -0000 1.27
+++ leader.c 9 Apr 2003 16:58:29 -0000 1.28
@@ -459,33 +459,6 @@
exit(code);
}
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- apr_filepath_set(ap_coredump_dir, pconf);
- apr_signal(sig, SIG_DFL);
- if (ap_my_pid == parent_pid) {
- ap_log_error(APLOG_MARK, 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
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
static void just_die(int sig)
{
clean_child_exit(0);
@@ -564,42 +537,16 @@
{
#ifndef NO_USE_SIGACTION
struct sigaction sa;
+#endif
+
+ if (!one_process) {
+ ap_fatal_signal_setup(ap_server_conf, pconf);
+ }
+#ifndef NO_USE_SIGACTION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
@@ -641,19 +588,6 @@
"sigaction(" AP_SIG_GRACEFUL_STRING ")");
#else
if (!one_process) {
- apr_signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- apr_signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- apr_signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- apr_signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- apr_signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
#ifdef SIGXCPU
apr_signal(SIGXCPU, SIG_DFL);
#endif /* SIGXCPU */
@@ -1104,6 +1038,7 @@
apr_thread_t *start_thread_id;
ap_my_pid = getpid();
+ ap_fatal_signal_child_setup(ap_server_conf);
apr_pool_create(&pchild, pconf);
/*stuff to do before we switch id's, so we have permissions.*/
1.8 +1 -0 httpd-2.0/server/mpm/experimental/leader/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/leader/mpm.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- mpm.h 3 Feb 2003 17:53:22 -0000 1.7
+++ mpm.h 9 Apr 2003 16:58:29 -0000 1.8
@@ -76,6 +76,7 @@
#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
#define AP_MPM_WANT_SIGNAL_SERVER
#define AP_MPM_WANT_SET_MAX_MEM_FREE
+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER
#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
#define AP_MPM_USES_POD 1
1.19 +1 -0 httpd-2.0/server/mpm/experimental/perchild/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/perchild/mpm.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- mpm.h 3 Feb 2003 17:53:23 -0000 1.18
+++ mpm.h 9 Apr 2003 16:58:29 -0000 1.19
@@ -77,6 +77,7 @@
#define AP_MPM_WANT_SET_COREDUMPDIR
#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
#define AP_MPM_WANT_SIGNAL_SERVER
+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER
#define AP_MPM_USES_POD
#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
1.138 +7 -60 httpd-2.0/server/mpm/experimental/perchild/perchild.c
Index: perchild.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/perchild/perchild.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- perchild.c 3 Feb 2003 17:53:23 -0000 1.137
+++ perchild.c 9 Apr 2003 16:58:29 -0000 1.138
@@ -324,21 +324,6 @@
exit(code);
}
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- apr_signal(sig, SIG_DFL);
- 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
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
static void just_die(int sig)
{
clean_child_exit(0);
@@ -418,42 +403,16 @@
{
#ifndef NO_USE_SIGACTION
struct sigaction sa;
+#endif
+ if (!one_process) {
+ ap_fatal_signal_setup(ap_server_conf, pconf);
+ }
+
+#ifndef NO_USE_SIGACTION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
@@ -495,19 +454,6 @@
"sigaction(" AP_SIG_GRACEFUL_STRING ")");
#else
if (!one_process) {
- apr_signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- apr_signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- apr_signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- apr_signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- apr_signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
#ifdef SIGXCPU
apr_signal(SIGXCPU, SIG_DFL);
#endif /* SIGXCPU */
@@ -1025,6 +971,7 @@
ap_listen_rec *lr;
my_pid = getpid();
+ ap_fatal_signal_child_setup(ap_server_conf);
child_num = child_num_arg;
apr_pool_create(&pchild, pconf);
1.5 +1 -0 httpd-2.0/server/mpm/experimental/threadpool/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/threadpool/mpm.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mpm.h 3 Feb 2003 17:53:23 -0000 1.4
+++ mpm.h 9 Apr 2003 16:58:29 -0000 1.5
@@ -76,6 +76,7 @@
#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
#define AP_MPM_WANT_SIGNAL_SERVER
#define AP_MPM_WANT_SET_MAX_MEM_FREE
+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER
#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
1.16 +7 -72 httpd-2.0/server/mpm/experimental/threadpool/threadpool.c
Index: threadpool.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/threadpool/threadpool.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- threadpool.c 3 Feb 2003 17:53:23 -0000 1.15
+++ threadpool.c 9 Apr 2003 16:58:29 -0000 1.16
@@ -535,33 +535,6 @@
exit(code);
}
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- apr_filepath_set(ap_coredump_dir, pconf);
- apr_signal(sig, SIG_DFL);
- if (ap_my_pid == parent_pid) {
- ap_log_error(APLOG_MARK, 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
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
static void just_die(int sig)
{
clean_child_exit(0);
@@ -635,42 +608,16 @@
{
#ifndef NO_USE_SIGACTION
struct sigaction sa;
+#endif
+ if (!one_process) {
+ ap_fatal_signal_setup(ap_server_conf, pconf);
+ }
+
+#ifndef NO_USE_SIGACTION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
@@ -712,19 +659,6 @@
"sigaction(" AP_SIG_GRACEFUL_STRING ")");
#else
if (!one_process) {
- apr_signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- apr_signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- apr_signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- apr_signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- apr_signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
#ifdef SIGXCPU
apr_signal(SIGXCPU, SIG_DFL);
#endif /* SIGXCPU */
@@ -1322,6 +1256,7 @@
apr_thread_t *start_thread_id;
ap_my_pid = getpid();
+ ap_fatal_signal_child_setup(ap_server_conf);
apr_pool_create(&pchild, pconf);
/*stuff to do before we switch id's, so we have permissions.*/
1.23 +1 -0 httpd-2.0/server/mpm/prefork/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/mpm.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- mpm.h 3 Feb 2003 17:53:24 -0000 1.22
+++ mpm.h 9 Apr 2003 16:58:30 -0000 1.23
@@ -79,6 +79,7 @@
#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
#define AP_MPM_WANT_SIGNAL_SERVER
#define AP_MPM_WANT_SET_MAX_MEM_FREE
+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER
#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
#define AP_MPM_USES_POD 1
1.274 +8 -61 httpd-2.0/server/mpm/prefork/prefork.c
Index: prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -r1.273 -r1.274
--- prefork.c 3 Feb 2003 17:53:24 -0000 1.273
+++ prefork.c 9 Apr 2003 16:58:30 -0000 1.274
@@ -353,27 +353,6 @@
}
#endif
-/* handle all varieties of core dumping signals */
-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_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
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
/*****************************************************************
* Connection structures and accounting...
*/
@@ -417,37 +396,16 @@
{
#ifndef NO_USE_SIGACTION
struct sigaction sa;
+#endif
+ if (!one_process) {
+ ap_fatal_signal_setup(ap_server_conf, pconf);
+ }
+
+#ifndef NO_USE_SIGACTION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)");
@@ -482,19 +440,6 @@
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")");
#else
if (!one_process) {
- apr_signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- apr_signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- apr_signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- apr_signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- apr_signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
#ifdef SIGXCPU
apr_signal(SIGXCPU, SIG_DFL);
#endif /* SIGXCPU */
@@ -554,6 +499,8 @@
ap_my_pid = getpid();
csd = NULL;
requests_this_child = 0;
+
+ ap_fatal_signal_child_setup(ap_server_conf);
/* Get a sub context for global allocations in this child, so that
* we can have cleanups occur when the child exits.
1.16 +1 -0 httpd-2.0/server/mpm/worker/mpm.h
Index: mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/mpm.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- mpm.h 3 Feb 2003 17:53:26 -0000 1.15
+++ mpm.h 9 Apr 2003 16:58:30 -0000 1.16
@@ -76,6 +76,7 @@
#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
#define AP_MPM_WANT_SIGNAL_SERVER
#define AP_MPM_WANT_SET_MAX_MEM_FREE
+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER
#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
1.135 +7 -72 httpd-2.0/server/mpm/worker/worker.c
Index: worker.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -r1.134 -r1.135
--- worker.c 3 Feb 2003 17:53:26 -0000 1.134
+++ worker.c 9 Apr 2003 16:58:30 -0000 1.135
@@ -374,33 +374,6 @@
exit(code);
}
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- apr_filepath_set(ap_coredump_dir, pconf);
- apr_signal(sig, SIG_DFL);
- if (ap_my_pid == parent_pid) {
- ap_log_error(APLOG_MARK, 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
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
static void just_die(int sig)
{
clean_child_exit(0);
@@ -474,42 +447,16 @@
{
#ifndef NO_USE_SIGACTION
struct sigaction sa;
+#endif
+ if (!one_process) {
+ ap_fatal_signal_setup(ap_server_conf, pconf);
+ }
+
+#ifndef NO_USE_SIGACTION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
- "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
@@ -551,19 +498,6 @@
"sigaction(" AP_SIG_GRACEFUL_STRING ")");
#else
if (!one_process) {
- apr_signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- apr_signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- apr_signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- apr_signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- apr_signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
#ifdef SIGXCPU
apr_signal(SIGXCPU, SIG_DFL);
#endif /* SIGXCPU */
@@ -1194,6 +1128,7 @@
apr_thread_t *start_thread_id;
ap_my_pid = getpid();
+ ap_fatal_signal_child_setup(ap_server_conf);
apr_pool_create(&pchild, pconf);
/*stuff to do before we switch id's, so we have permissions.*/