init: use exec_spawn instead of exec

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-12-20 12:30:57 +08:00 committed by Xiang Xiao
parent 10ccba6671
commit 0bb32f27c0
2 changed files with 17 additions and 4 deletions

View File

@ -347,6 +347,10 @@ config INIT_ENTRYPOINT
applications this is of the form 'app_main' where 'app' is the application
name. If not defined, INIT_ENTRYPOINT defaults to "main".
config INIT_ENTRYNAME
string "Application entry name"
default INIT_ENTRYPOINT
endif # INIT_ENTRY
if INIT_FILE

View File

@ -234,6 +234,9 @@ static inline void nx_start_application(void)
FAR char *const *argv = NULL;
#endif
int ret;
#ifdef CONFIG_INIT_FILE
posix_spawnattr_t attr;
#endif
#ifdef CONFIG_BOARD_LATE_INITIALIZE
/* Perform any last-minute, board-specific initialization, if so
@ -255,11 +258,11 @@ static inline void nx_start_application(void)
#ifdef CONFIG_BUILD_PROTECTED
DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
ret = nxtask_create("init", CONFIG_INIT_PRIORITY,
ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
CONFIG_INIT_STACKSIZE,
USERSPACE->us_entrypoint, argv);
#else
ret = nxtask_create("init", CONFIG_INIT_PRIORITY,
ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
CONFIG_INIT_STACKSIZE,
(main_t)CONFIG_INIT_ENTRYPOINT, argv);
#endif
@ -283,8 +286,14 @@ static inline void nx_start_application(void)
sinfo("Starting init task: %s\n", CONFIG_INIT_FILEPATH);
ret = exec(CONFIG_INIT_FILEPATH, argv,
CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS);
posix_spawnattr_init(&attr);
attr.priority = CONFIG_INIT_PRIORITY;
#ifndef CONFIG_ARCH_ADDRENV
attr.stacksize = CONFIG_INIT_STACKSIZE;
#endif
ret = exec_spawn(CONFIG_INIT_FILEPATH, argv,
CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS, &attr);
DEBUGASSERT(ret >= 0);
#endif