]> granicus.if.org Git - apache/commitdiff
Put back the process_child_status code from 1.3. Handling of synchronous
authorManoj Kasichainula <manoj@apache.org>
Tue, 10 Aug 1999 21:18:43 +0000 (21:18 +0000)
committerManoj Kasichainula <manoj@apache.org>
Tue, 10 Aug 1999 21:18:43 +0000 (21:18 +0000)
signals like SEGV and FPE is still a bit dodgy, though, so this won't
accomplish much by itself.

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

server/mpm/dexter/dexter.c
server/mpm/mpmt_pthread/mpmt_pthread.c

index 3046bdf345f8f179bd1057b354395324f1d9e115..4cde4c99f8f0b56008c5c202b0b50ad6a2d32d86 100644 (file)
@@ -744,6 +744,57 @@ static void set_signals(void)
 
 #endif
 }
+
+static void process_child_status(int pid, ap_wait_t status)
+{
+    /* Child died... if it died due to a fatal error,
+       * we should simply bail out.
+       */
+    if ((WIFEXITED(status)) &&
+       WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
+       ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server_conf,
+                       "Child %d returned a Fatal error... \n"
+                       "Apache is exiting!",
+                       pid);
+       exit(APEXIT_CHILDFATAL);
+    }
+    if (WIFSIGNALED(status)) {
+       switch (WTERMSIG(status)) {
+       case SIGTERM:
+       case SIGHUP:
+       case SIGUSR1:
+       case SIGKILL:
+           break;
+       default:
+#ifdef SYS_SIGLIST
+#ifdef WCOREDUMP
+           if (WCOREDUMP(status)) {
+               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                            server_conf,
+                            "child pid %d exit signal %s (%d), "
+                            "possible coredump in %s",
+                            pid, (WTERMSIG(status) >= NumSIG) ? "" : 
+                            SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
+                            ap_coredump_dir);
+           }
+           else {
+#endif
+               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                            server_conf,
+                            "child pid %d exit signal %s (%d)", pid,
+                            SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
+#ifdef WCOREDUMP
+           }
+#endif
+#else
+           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                        server_conf,
+                        "child pid %d exit signal %d",
+                        pid, WTERMSIG(status));
+#endif
+       }
+    }
+}
  
 static int setup_listeners(pool *pconf, server_rec *s)
 {
@@ -1253,6 +1304,8 @@ static void server_main_loop(int remaining_children_to_start)
         pid = wait_or_timeout(&status);
         
         if (pid >= 0) {
+            process_child_status(pid, status);
+            /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = find_child_by_pid(pid);
             if (child_slot >= 0) {
                 ap_update_child_status(child_slot, SERVER_DEAD);
index 60ce966d64820a513859fced8e4e830e0d56eea8..9c4c0b65d7a7f0fee446c8dd08c1f52142e152d6 100644 (file)
@@ -568,7 +568,7 @@ static void sig_coredump(int sig)
 {
     chdir(ap_coredump_dir);
     signal(sig, SIG_DFL);
-    kill(getpid(), sig);
+    kill(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
@@ -752,6 +752,57 @@ static void set_signals(void)
 
 #endif
 }
+
+static void process_child_status(int pid, ap_wait_t status)
+{
+    /* Child died... if it died due to a fatal error,
+       * we should simply bail out.
+       */
+    if ((WIFEXITED(status)) &&
+       WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
+       ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server_conf,
+                       "Child %d returned a Fatal error... \n"
+                       "Apache is exiting!",
+                       pid);
+       exit(APEXIT_CHILDFATAL);
+    }
+    if (WIFSIGNALED(status)) {
+       switch (WTERMSIG(status)) {
+       case SIGTERM:
+       case SIGHUP:
+       case SIGUSR1:
+       case SIGKILL:
+           break;
+       default:
+#ifdef SYS_SIGLIST
+#ifdef WCOREDUMP
+           if (WCOREDUMP(status)) {
+               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                            server_conf,
+                            "child pid %d exit signal %s (%d), "
+                            "possible coredump in %s",
+                            pid, (WTERMSIG(status) >= NumSIG) ? "" : 
+                            SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
+                            ap_coredump_dir);
+           }
+           else {
+#endif
+               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                            server_conf,
+                            "child pid %d exit signal %s (%d)", pid,
+                            SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
+#ifdef WCOREDUMP
+           }
+#endif
+#else
+           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+                        server_conf,
+                        "child pid %d exit signal %d",
+                        pid, WTERMSIG(status));
+#endif
+       }
+    }
+}
  
 static int setup_listeners(pool *pconf, server_rec *s)
 {
@@ -1296,6 +1347,8 @@ static void server_main_loop(int remaining_children_to_start)
         pid = wait_or_timeout(&status);
         
         if (pid >= 0) {
+            process_child_status(pid, status);
+            /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = find_child_by_pid(pid);
             if (child_slot >= 0) {
                 for (i = 0; i < ap_threads_per_child; i++)