From: Jan Kaluža Date: Mon, 18 Aug 2014 07:43:43 +0000 (+0000) Subject: prefork: Ignore SIGINT in child. This fixes race-condition in signals handling X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20656c3b77cc548b59fea3bde5e2b7705d71c427;p=thirdparty%2Fapache%2Fhttpd.git 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). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1618555 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 8790ec086eb..d6c038bcee5 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -222,6 +222,9 @@ static void clean_child_exit(int code) { mpm_state = AP_MPMQ_STOPPING; + apr_signal(SIGHUP, SIG_IGN); + apr_signal(SIGTERM, SIG_IGN); + if (pchild) { apr_pool_destroy(pchild); } @@ -817,6 +820,13 @@ static int make_child(server_rec *s, int slot) */ 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. */