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 84f798d434d8c9c7da541837d3686dc71cbc7b02
Author: wangjianyu3 <[email protected]>
AuthorDate: Sat Oct 11 21:10:28 2025 +0800

    system/nxinit: Add exec_start support for action
    
    Format: exec_start <service>
    
    Start the specified service and pause the processing of any additional
    initialization commands until the service completes its execution. This
    command operates similarly to the `exec` command; the key difference is
    that it utilizes an existing service definition rather than requiring
    the `exec` argument vector.
    
    This feature is particularly intended for use with the `reboot_on_failure`
    built-in command to perform all types of essential checks during system 
boot.
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/nxinit/builtin.c | 16 ++++++++++++++--
 system/nxinit/init.c    | 11 ++++++-----
 system/nxinit/service.c |  2 +-
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/system/nxinit/builtin.c b/system/nxinit/builtin.c
index a64a46425..d300457f7 100644
--- a/system/nxinit/builtin.c
+++ b/system/nxinit/builtin.c
@@ -53,6 +53,8 @@ struct cmd_map_s
 
 static int cmd_trigger(FAR struct action_manager_s *am,
                        int argc, FAR char **argv);
+static int cmd_exec_start(FAR struct action_manager_s *am,
+                          int argc, FAR char **argv);
 static int cmd_start(FAR struct action_manager_s *am,
                      int argc, FAR char **argv);
 static int cmd_stop(FAR struct action_manager_s *am,
@@ -73,6 +75,7 @@ static const struct cmd_map_s g_builtin[] =
   {"class_start", 2, 2, cmd_class_start},
   {"class_stop", 2, 2, cmd_class_stop},
   {"exec", 3, 99, cmd_exec},
+  {"exec_start", 2, 2, cmd_exec_start},
   {"start", 2, 2, cmd_start},
   {"stop", 2, 2, cmd_stop},
   {"trigger", 2, 2, cmd_trigger},
@@ -94,8 +97,8 @@ static int cmd_class_stop(FAR struct action_manager_s *am,
   return init_service_stop_by_class(am->sm, argv[1]);
 }
 
-static int cmd_start(FAR struct action_manager_s *am,
-                     int argc, FAR char **argv)
+static int cmd_exec_start(FAR struct action_manager_s *am,
+                          int argc, FAR char **argv)
 {
   FAR struct service_s *service;
 
@@ -109,6 +112,15 @@ static int cmd_start(FAR struct action_manager_s *am,
   return init_service_start(service);
 }
 
+static int cmd_start(FAR struct action_manager_s *am,
+                     int argc, FAR char **argv)
+{
+  int ret;
+
+  ret = cmd_exec_start(am, argc, argv);
+  return ret < 0 ? ret : 0;
+}
+
 static int cmd_stop(FAR struct action_manager_s *am,
                     int argc, FAR char **argv)
 {
diff --git a/system/nxinit/init.c b/system/nxinit/init.c
index 1f5396265..52b71728f 100644
--- a/system/nxinit/init.c
+++ b/system/nxinit/init.c
@@ -105,17 +105,18 @@ static void reap_process(FAR struct service_manager_s *sm,
           continue;
         }
 
+      if (pid == am->pid_running)
+        {
+          name = am->running->argv[0];
+          init_action_reap_command(am);
+        }
+
       service = init_service_find_by_pid(sm, pid);
       if (service != NULL)
         {
           name = service->argv[1];
           init_service_reap(service);
         }
-      else if (pid == am->pid_running)
-        {
-          name = am->running->argv[0];
-          init_action_reap_command(am);
-        }
 
       init_log(service ? LOG_WARNING : LOG_DEBUG,
                "%s '%s' pid %d exited %s %d",
diff --git a/system/nxinit/service.c b/system/nxinit/service.c
index 8f456c920..49f4d4c49 100644
--- a/system/nxinit/service.c
+++ b/system/nxinit/service.c
@@ -414,7 +414,7 @@ int init_service_start(FAR struct service_s *service)
   remove_flags(service, SVC_DISABLED);
   init_info("Started service '%s' pid %d", service->argv[1], service->pid);
 
-  return 0;
+  return service->pid;
 }
 
 int init_service_stop(FAR struct service_s *service)

Reply via email to