This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 5c31efbd2 system/nxinit: Run builtin commands with the original signal
mask.
5c31efbd2 is described below
commit 5c31efbd2c2b101c8ed36b4b7471b36ab5b00fa3
Author: raiden00pl <[email protected]>
AuthorDate: Thu Oct 8 11:33:13 2026 +0200
system/nxinit: Run builtin commands with the original signal mask.
init blocks all signals and only unblocks them in ppoll(). Builtin
commands run in the init task, so tasks and threads they create
inherited a mask with all signals blocked: e.g. the NTP client started
by "netinit" never received the wakeup signal of ntpc_stop(), and
ntpcstop waited for the client's current sleep to end.
Save the mask init had before blocking and run builtin commands with it,
keeping SIGCHLD blocked so that a child exiting meanwhile still wakes
up ppoll().
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <[email protected]>
---
system/nxinit/action.h | 3 +++
system/nxinit/builtin.c | 17 ++++++++++++++++-
system/nxinit/init.c | 2 +-
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/system/nxinit/action.h b/system/nxinit/action.h
index 48f672951..b1d547b0a 100644
--- a/system/nxinit/action.h
+++ b/system/nxinit/action.h
@@ -28,6 +28,7 @@
****************************************************************************/
#include <nuttx/list.h>
+#include <signal.h>
#include <time.h>
@@ -85,6 +86,8 @@ struct action_manager_s
FAR struct service_manager_s *sm;
FAR struct init_poller_s *prop;
+
+ sigset_t sigmask; /* Signal mask before init blocked all */
};
/* Event evaluation result reported by init_action_event_cb.
diff --git a/system/nxinit/builtin.c b/system/nxinit/builtin.c
index c12f8cef4..1e3104a45 100644
--- a/system/nxinit/builtin.c
+++ b/system/nxinit/builtin.c
@@ -370,6 +370,8 @@ int init_builtin_run(FAR struct action_manager_s *am,
char cmd[CONFIG_SYSTEM_NXINIT_RC_LINE_MAX];
posix_spawnattr_t attr;
FAR char *args[4];
+ sigset_t blocked;
+ sigset_t builtin;
sigset_t mask;
pid_t pid;
size_t i;
@@ -387,7 +389,20 @@ int init_builtin_run(FAR struct action_manager_s *am,
}
init_info("Executing command '%s'", argv[0]);
- return g_builtin[i].func(am, argc, argv);
+
+ /* Init blocks all signals. Run the builtin command with the
+ * original mask, as tasks and threads it creates (e.g. the NTP
+ * client and the network monitor started by netinit) inherit
+ * the mask of this task. Keep SIGCHLD blocked so that a child
+ * exiting meanwhile still wakes up ppoll() in init.
+ */
+
+ builtin = am->sigmask;
+ sigaddset(&builtin, SIGCHLD);
+ sigprocmask(SIG_SETMASK, &builtin, &blocked);
+ ret = g_builtin[i].func(am, argc, argv);
+ sigprocmask(SIG_SETMASK, &blocked, NULL);
+ return ret;
}
}
diff --git a/system/nxinit/init.c b/system/nxinit/init.c
index f66dc4149..ddb783db2 100644
--- a/system/nxinit/init.c
+++ b/system/nxinit/init.c
@@ -228,7 +228,7 @@ int main(int argc, FAR char *argv[])
int r;
sigfillset(&mask);
- r = sigprocmask(SIG_BLOCK, &mask, NULL);
+ r = sigprocmask(SIG_BLOCK, &mask, &am.sigmask);
sigemptyset(&mask);
if (r < 0)
{