This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 045160d3bbd6a8a81b0355a7c672dfa9b9fb4ac8
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Oct 18 12:57:32 2026 +0200

    system/nxinit: Install a handler for SIGCHLD.
    
    init waits in ppoll() and expects SIGCHLD to interrupt it when a child
    exits, but it installed no handler for SIGCHLD.  An ignored signal need
    not interrupt ppoll(), and with CONFIG_SIG_DISCARD_IGNORED it does not:
    init then never sees that a command of init.rc has finished.
    
    Install an empty handler for SIGCHLD.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 system/nxinit/init.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/system/nxinit/init.c b/system/nxinit/init.c
index cda3317d9..d0329a114 100644
--- a/system/nxinit/init.c
+++ b/system/nxinit/init.c
@@ -31,6 +31,7 @@
 #include <poll.h>
 #include <sched.h>
 #include <stdio.h>
+#include <signal.h>
 #include <string.h>
 #include <sys/boardctl.h>
 #include <sys/param.h>
@@ -58,6 +59,16 @@
  * Private Functions
  ****************************************************************************/
 
+/* An empty handler: SIGCHLD must interrupt ppoll() when a child exits.  A
+ * signal without a handler is ignored and need not interrupt it.
+ */
+
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+static void init_sigchld(int signo)
+{
+}
+#endif
+
 static void reap_process(FAR struct service_manager_s *sm,
                          FAR struct action_manager_s *am)
 {
@@ -224,6 +235,9 @@ int main(int argc, FAR char *argv[])
     };
 
   struct pollfd pfds[nitems(poller)];
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+  struct sigaction sa;
+#endif
   sigset_t mask;
   size_t i;
   int r;
@@ -233,6 +247,13 @@ int main(int argc, FAR char *argv[])
            ACTION_PROP_KEY_TRIGGER ".core%d", sched_getcpu());
 #endif
 
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+  memset(&sa, 0, sizeof(sa));
+  sa.sa_handler = init_sigchld;
+  sigemptyset(&sa.sa_mask);
+  sigaction(SIGCHLD, &sa, NULL);
+#endif
+
   sigfillset(&mask);
   r = sigprocmask(SIG_BLOCK, &mask, &am.sigmask);
   sigemptyset(&mask);

Reply via email to