]> granicus.if.org Git - apache/commitdiff
Merge r1618555 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 16 Aug 2017 16:49:12 +0000 (16:49 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 16 Aug 2017 16:49:12 +0000 (16:49 +0000)
prefork: Ignore SIGINT in child. This fixes race-condition in signals handling
when httpd is runnning on foreground and user hits ctrl+c. In this case, SIGINT
is sent to all children followed by SIGTERM from the main process, which
interrupts the SIGINT handler and leads to inconsistency (process freezes
or crashes).

Submitted by: jkaluza
Reviewed by: ylavic, jorton, jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1805222 13f79535-47bb-0310-9956-ffa450edef68

STATUS
server/mpm/prefork/prefork.c

diff --git a/STATUS b/STATUS
index e812805cb9a6265e906e537833e9764645447bba..4bc28539d8653acf0ff3ad124e2b701c2712746c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -116,17 +116,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   *) prefork: This fixes race-condition in signals handling when httpd is
-               runnning on foreground and user hits ctrl+c
-     trunk patch: http://svn.apache.org/r1618555
-     2.4.x patch: svn merge -c 1618555 ^/httpd/httpd/trunk .
-     +1: ylavic, jorton, jim
-     jailetc36: untested because I'm unsure on how to reproduce the race, but
-                the patch description looks straighforward.
-                If confirmed, it would worth, IMHO, a CHANGE entry and maybe a
-                2.2.x backport.
-                [jorton: race, so hard to repro, triggered regularly w/docker.]
-
   *) core: ap_server_config_defines and ap_server_{pre,post}_read_config
            constantness and bytes saving, no functional change.
      trunk patch: http://svn.apache.org/r1713043
index 559f90a95e2a319042c5b22b6c4d369a06b6b8ad..a386a757ffd2d11ed05f3d100dff90587e966d56 100644 (file)
@@ -220,6 +220,9 @@ static void clean_child_exit(int code)
 {
     retained->mpm->mpm_state = AP_MPMQ_STOPPING;
 
+    apr_signal(SIGHUP, SIG_IGN);
+    apr_signal(SIGTERM, SIG_IGN);
+
     if (pchild) {
         apr_pool_destroy(pchild);
     }
@@ -699,6 +702,13 @@ static int make_child(server_rec *s, int slot, int bucket)
          */
         apr_signal(SIGHUP, just_die);
         apr_signal(SIGTERM, just_die);
+        /* Ignore SIGINT in child. This fixes race-condition in signals
+         * handling when httpd is runnning on foreground and user hits ctrl+c.
+         * In this case, SIGINT is sent to all children followed by SIGTERM
+         * from the main process, which interrupts the SIGINT handler and
+         * leads to inconsistency.
+         */
+        apr_signal(SIGINT, SIG_IGN);
         /* The child process just closes listeners on AP_SIG_GRACEFUL.
          * The pod is used for signalling the graceful restart.
          */