[PATCH 1/3] ipcpd: Don't use sigwaitinfo() on OS X

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 3 Sep 2021 18:35:52 +0200

Apparently that function isn't implemented on some versions of OS
X. On these systems, we can just use sigwait, but now the IPCP will
also accept signals not coming from the IRMd.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/ipcpd/ipcp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index ab2f88f..3e1da8c 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -844,9 +844,12 @@ int ipcp_boot()
 
 void ipcp_shutdown()
 {
+
         siginfo_t info;
         sigset_t  sigset;
-
+#ifdef __APPLE__
+        int       sig;
+#endif
         sigemptyset(&sigset);
         sigaddset(&sigset, SIGINT);
         sigaddset(&sigset, SIGQUIT);
@@ -856,11 +859,20 @@ void ipcp_shutdown()
 
         while(ipcp_get_state() != IPCP_NULL &&
               ipcp_get_state() != IPCP_SHUTDOWN) {
+#ifdef __APPLE__
+                if (sigwait(&sigset, &sig) < 0) {
+#else
                 if (sigwaitinfo(&sigset, &info) < 0) {
+#endif
                         log_warn("Bad signal.");
                         continue;
                 }
 
+#ifdef __APPLE__
+                memset(&info, 0, sizeof(info));
+                info.si_signo = sig;
+                info.si_pid   = ipcpi.irmd_pid;
+#endif
                 switch(info.si_signo) {
                 case SIGINT:
                 case SIGTERM:
-- 
2.33.0


Other related posts:

  • » [PATCH 1/3] ipcpd: Don't use sigwaitinfo() on OS X - Dimitri Staessens