Skip to content

Commit 5a66436

Browse files
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]>
1 parent b636a88 commit 5a66436

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

system/nxinit/builtin.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ struct cmd_map_s
5353

5454
static int cmd_trigger(FAR struct action_manager_s *am,
5555
int argc, FAR char **argv);
56+
static int cmd_exec_start(FAR struct action_manager_s *am,
57+
int argc, FAR char **argv);
5658
static int cmd_start(FAR struct action_manager_s *am,
5759
int argc, FAR char **argv);
5860
static int cmd_stop(FAR struct action_manager_s *am,
@@ -73,6 +75,7 @@ static const struct cmd_map_s g_builtin[] =
7375
{"class_start", 2, 2, cmd_class_start},
7476
{"class_stop", 2, 2, cmd_class_stop},
7577
{"exec", 3, 99, cmd_exec},
78+
{"exec_start", 2, 2, cmd_exec_start},
7679
{"start", 2, 2, cmd_start},
7780
{"stop", 2, 2, cmd_stop},
7881
{"trigger", 2, 2, cmd_trigger},
@@ -94,8 +97,8 @@ static int cmd_class_stop(FAR struct action_manager_s *am,
9497
return init_service_stop_by_class(am->sm, argv[1]);
9598
}
9699

97-
static int cmd_start(FAR struct action_manager_s *am,
98-
int argc, FAR char **argv)
100+
static int cmd_exec_start(FAR struct action_manager_s *am,
101+
int argc, FAR char **argv)
99102
{
100103
FAR struct service_s *service;
101104

@@ -109,6 +112,15 @@ static int cmd_start(FAR struct action_manager_s *am,
109112
return init_service_start(service);
110113
}
111114

115+
static int cmd_start(FAR struct action_manager_s *am,
116+
int argc, FAR char **argv)
117+
{
118+
int ret;
119+
120+
ret = cmd_exec_start(am, argc, argv);
121+
return ret < 0 ? ret : 0;
122+
}
123+
112124
static int cmd_stop(FAR struct action_manager_s *am,
113125
int argc, FAR char **argv)
114126
{

system/nxinit/init.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,18 @@ static void reap_process(FAR struct service_manager_s *sm,
105105
continue;
106106
}
107107

108+
if (pid == am->pid_running)
109+
{
110+
name = am->running->argv[0];
111+
init_action_reap_command(am);
112+
}
113+
108114
service = init_service_find_by_pid(sm, pid);
109115
if (service)
110116
{
111117
name = service->argv[1];
112118
init_service_reap(service);
113119
}
114-
else if (pid == am->pid_running)
115-
{
116-
name = am->running->argv[0];
117-
init_action_reap_command(am);
118-
}
119120

120121
init_log(service ? LOG_WARNING : LOG_DEBUG,
121122
"%s '%s' pid %d exited %s %d",

system/nxinit/service.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ int init_service_start(FAR struct service_s *service)
414414
remove_flags(service, SVC_DISABLED);
415415
init_info("Started service '%s' pid %d", service->argv[1], service->pid);
416416

417-
return 0;
417+
return service->pid;
418418
}
419419

420420
int init_service_stop(FAR struct service_s *service)

0 commit comments

Comments
 (0)