# HG changeset patch
# User Maxim Dounin <mdou...@mdounin.ru>
# Date 1748209526 -10800
#      Mon May 26 00:45:26 2025 +0300
# Node ID 95e5cc6c73d1b94a59c4eea26bd2956a1cdc2f3d
# Parent  7a595fa6ade10f801f6e9bc84a7fd8fc1f9cca21
Compatibility with systems without SA_SIGINFO in sigaction().

This change restores compatibility with some older systems without
SA_SIGINFO support, broken by 6985:23ecffd5bcfe.  Notably, this fixes
compilation on MINIX.

diff --git a/auto/unix b/auto/unix
--- a/auto/unix
+++ b/auto/unix
@@ -1043,3 +1043,16 @@ ngx_feature_test='struct addrinfo *res;
                   if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 
1;
                   freeaddrinfo(res)'
 . auto/feature
+
+
+ngx_feature="sigaction(SA_SIGINFO)"
+ngx_feature_name="NGX_HAVE_SIGINFO"
+ngx_feature_run=no
+ngx_feature_incs="#include <signal.h>"
+ngx_feature_path=
+ngx_feature_libs=
+ngx_feature_test="struct sigaction sa;
+                  sa.sa_flags = SA_SIGINFO;
+                  sa.sa_sigaction = NULL;
+                  if (sigaction(0, &sa, NULL) == -1) return 1;"
+. auto/feature
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -15,13 +15,21 @@ typedef struct {
     int     signo;
     char   *signame;
     char   *name;
+#if (NGX_HAVE_SIGINFO)
     void  (*handler)(int signo, siginfo_t *siginfo, void *ucontext);
+#else
+    void  (*handler)(int signo);
+#endif
 } ngx_signal_t;
 
 
 
 static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
+#if (NGX_HAVE_SIGINFO)
 static void ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext);
+#else
+static void ngx_signal_handler(int signo);
+#endif
 static void ngx_process_get_status(void);
 static void ngx_unlock_mutexes(ngx_pid_t pid);
 
@@ -291,8 +299,12 @@ ngx_init_signals(ngx_log_t *log)
         ngx_memzero(&sa, sizeof(struct sigaction));
 
         if (sig->handler) {
+#if (NGX_HAVE_SIGINFO)
             sa.sa_sigaction = sig->handler;
             sa.sa_flags = SA_SIGINFO;
+#else
+            sa.sa_handler = sig->handler;
+#endif
 
         } else {
             sa.sa_handler = SIG_IGN;
@@ -315,8 +327,13 @@ ngx_init_signals(ngx_log_t *log)
 }
 
 
+#if (NGX_HAVE_SIGINFO)
 static void
 ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext)
+#else
+static void
+ngx_signal_handler(int signo)
+#endif
 {
     char            *action;
     ngx_int_t        ignore;
@@ -441,12 +458,15 @@ ngx_signal_handler(int signo, siginfo_t 
         break;
     }
 
+#if (NGX_HAVE_SIGINFO)
     if (siginfo && siginfo->si_pid) {
         ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0,
                       "signal %d (%s) received from %P%s",
                       signo, sig->signame, siginfo->si_pid, action);
 
-    } else {
+    } else
+#endif
+    {
         ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0,
                       "signal %d (%s) received%s",
                       signo, sig->signame, action);

Reply via email to