From: Joe Orton Date: Mon, 19 Jan 2026 11:05:38 +0000 (+0000) Subject: Add --enable-sigusr2 to use SIGUSR2 rather than SIGWINCH for graceful X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8a53d147cb834fce06f88b055a4bb6ba3219df2;p=thirdparty%2Fapache%2Fhttpd.git Add --enable-sigusr2 to use SIGUSR2 rather than SIGWINCH for graceful stop, which requires APR 1.7+. * configure.in: Add --enable-sigusr2; define AP_SIG_GRACEFUL_STOP* in ap_config.h. * include/mpm_common.h: Define AP_SIG_GRACEFUL_STOP* conditionally. * server/mpm/prefork/prefork.c (child_main): Don't mention SIGWINCH. PR: 50669 Github: closes #595 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1931418 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/changes-entries/pr50669.txt b/changes-entries/pr50669.txt new file mode 100644 index 0000000000..3142529efd --- /dev/null +++ b/changes-entries/pr50669.txt @@ -0,0 +1,3 @@ + *) Unix MPMs: Add --enable-sigusr2 configure option to use + SIGUSR2 rather than SIGWINCH for graceful-stop. PR 50669 + [Joe Orton] diff --git a/configure.in b/configure.in index 27f6f85712..b64c37b778 100644 --- a/configure.in +++ b/configure.in @@ -830,6 +830,24 @@ if test "$apache_need_shared" = "yes"; then shared_build="shared-build" fi +ap_graceful_sig=WINCH +AC_ARG_ENABLE(sigusr2, + APACHE_HELP_STRING(--enable-sigusr2,Use SIGUSR2 for graceful stop), +[ + case $APR_VERSION in + 0.*|1.[[0-6]].*) AC_MSG_ERROR([APR 1.7 or later is required to use SIGUSR2]) ;; + esac + ap_graceful_sig=USR2 +]) +AC_MSG_NOTICE([using signal SIG$ap_graceful_sig for graceful stop]) + +AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP], [SIG$ap_graceful_sig], + [Signal to use for graceful stop]) +AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP_STRING], + ["SIG$ap_graceful_sig"], [Signal name in use for graceful stop]) +AC_DEFINE_UNQUOTED([AP_SIG_GRACEFUL_STOP_SHORT], + [$ap_graceful_sig], [Short signal name in use for graceful stop]) + dnl enable_so tells us if *any* modules can be built as DSOs if test "$enable_so" = "yes" -o "$enable_so" = "static"; then diff --git a/include/mpm_common.h b/include/mpm_common.h index 08fc380b86..f60c473d53 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -80,14 +80,20 @@ extern "C" { /* Signal used to gracefully restart (as a quoted string) */ #define AP_SIG_GRACEFUL_STRING "SIGUSR1" +#ifndef AP_SIG_GRACEFUL_STOP /* Signal used to gracefully stop */ #define AP_SIG_GRACEFUL_STOP SIGWINCH +#endif +#ifndef AP_SIG_GRACEFUL_STOP_SHORT /* Signal used to gracefully stop (without SIG prefix) */ #define AP_SIG_GRACEFUL_STOP_SHORT WINCH +#endif +#ifndef AP_SIG_GRACEFUL_STOP_STRING /* Signal used to gracefully stop (as a quoted string) */ #define AP_SIG_GRACEFUL_STOP_STRING "SIGWINCH" +#endif /** * Callback function used for ap_reclaim_child_processes() and diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index d9837725c9..3de062f367 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -541,10 +541,10 @@ static void child_main(int child_num_arg, int child_bucket) status = apr_pollset_add(pollset, pfd); if (status != APR_SUCCESS) { - /* If the child processed a SIGWINCH before setting up the - * pollset, this error path is expected and harmless, - * since the listener fd was already closed; so don't - * pollute the logs in that case. */ + /* If the child processed a graceful-stop signal before + * setting up the pollset, this error path is expected and + * harmless, since the listener fd was already closed; so + * don't pollute the logs in that case. */ if (!die_now) { ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, APLOGNO(00157) "Couldn't add listener to pollset; check system or user limits");